💾 Archived View for tris.fyi › pydoc › _collections captured on 2023-04-26 at 13:17:19. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
High performance data structures. - deque: ordered collection accessible from endpoints only - defaultdict: dict subclass with a default value factory
Dictionary that remembers insertion order
clear(...) od.clear() -> None. Remove all items from od.
copy(...) od.copy() -> a shallow copy of od
fromkeys(iterable, value=None) Create a new ordered dictionary with keys from iterable and values set to value.
get(self, key, default=None, /) Return the value for key if key is in the dictionary, else default.
items(...)
keys(...)
move_to_end(self, /, key, last=True) Move an existing element to the end (or beginning if last is false). Raise KeyError if the element does not exist.
pop(...) od.pop(key[,default]) -> v, remove specified key and return the corresponding value. If the key is not found, return the default if given; otherwise, raise a KeyError.
popitem(self, /, last=True) Remove and return a (key, value) pair from the dictionary. Pairs are returned in LIFO order if last is true or FIFO order if false.
setdefault(self, /, key, default=None) Insert key with a value of default if key is not in the dictionary. Return the value for key if key is in the dictionary, else default.
update(...)
values(...)
defaultdict(default_factory=None, /, [...]) --> dict with default factory The default factory is called without arguments to produce a new value when a key is not present, in __getitem__ only. A defaultdict compares equal to a dict with the same items. All remaining arguments are treated the same as if they were passed to the dict constructor, including keyword arguments.
clear(...) D.clear() -> None. Remove all items from D.
copy(...) D.copy() -> a shallow copy of D.
fromkeys(iterable, value=None, /) Create a new dictionary with keys from iterable and values set to value.
get(self, key, default=None, /) Return the value for key if key is in the dictionary, else default.
items(...) D.items() -> a set-like object providing a view on D's items
keys(...) D.keys() -> a set-like object providing a view on D's keys
pop(...) D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If the key is not found, return the default if given; otherwise, raise a KeyError.
popitem(self, /) Remove and return a (key, value) pair as a 2-tuple. Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
setdefault(self, key, default=None, /) Insert key with a value of default if key is not in the dictionary. Return the value for key if key is in the dictionary, else default.
update(...) D.update([E, ]**F) -> None. Update D from dict/iterable E and F. If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values(...) D.values() -> an object providing a view on D's values
default_factory = <member 'default_factory' of 'collections.defaultdict' objects> Factory for default value called by __missing__().
deque([iterable[, maxlen]]) --> deque object A list-like sequence optimized for data accesses near its endpoints.
append(...) Add an element to the right side of the deque.
appendleft(...) Add an element to the left side of the deque.
clear(...) Remove all elements from the deque.
copy(...) Return a shallow copy of a deque.
count(...) D.count(value) -> integer -- return number of occurrences of value
extend(...) Extend the right side of the deque with elements from the iterable
extendleft(...) Extend the left side of the deque with elements from the iterable
index(...) D.index(value, [start, [stop]]) -> integer -- return first index of value. Raises ValueError if the value is not present.
insert(...) D.insert(index, object) -- insert object before index
pop(...) Remove and return the rightmost element.
popleft(...) Remove and return the leftmost element.
remove(...) D.remove(value) -- remove first occurrence of value.
reverse(...) D.reverse() -- reverse *IN PLACE*
rotate(...) Rotate the deque n steps to the right (default n=1). If n is negative, rotates left.
maxlen = <attribute 'maxlen' of 'collections.deque' objects> maximum size of a deque or None if unbounded