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:
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.
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, ie, O(n).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.