0

This might be a very stupid question but I can't understand what the three dots stands for in a python def. I was trying to comprehend the cost of the in operator in a deque object (from the collections module), so I navigated through the code and here's what I found:

img

I thought they mean the method will use the "upper" definition when called, but if I navigate to the overridden method I can't find nothing if not an abstract method in the Container class.. so I still don't get how the in operator works on a deque object.

snakecharmerb
  • 47,570
  • 11
  • 100
  • 153
  • 1
    About "..." and .pyi file, refer to [stackoverflow.com/q/41734836](https://stackoverflow.com/questions/41734836/what-does-i-represent-in-python-pyi-extension) – Register Sole Mar 17 '19 at 16:27
  • @RegisterSole There's nothing about `...` in that question. – Barmar Mar 17 '19 at 16:42
  • @Barmar Based on the answer there, a .pyi file describes the interface of the module **without** any implementation. Hence, `...` really means ... in ordinary text. That is, the part of the text is deliberately omitted as it is irrelevant. – Register Sole Mar 17 '19 at 16:48

1 Answers1

1

You are looking at a .pyi stub file. Referring to this post, a stub file, as the name suggests, is only meant to describe the interface and not the implementation inside. Hence, ... in a Python def really means that this file is just a def and you cannot find the implementation here.

Regarding your question about the cost of in operator in deque, refer to https://wiki.python.org/moin/TimeComplexity

It mentions deque is represented internally as a doubly-linked list, and also mentions that in operator for a list has O(n) complexity. I don't think it being a doubly-linked list changes the time complexity, as you would still need to go through each element, i.e., O(n).

Register Sole
  • 3,206
  • 1
  • 14
  • 22