chunk_id
stringlengths
36
36
source
stringclasses
35 values
source_url
stringlengths
0
290
upstream_license
stringclasses
1 value
document_id
stringlengths
36
36
chunk_index
int64
0
324k
retrieved_at
stringclasses
2 values
chunker_version
stringclasses
4 values
content_hash
stringlengths
15
64
content
stringlengths
50
44.7k
namespace
stringclasses
9 values
source_name
stringclasses
35 values
raw_text
stringlengths
50
44.7k
cleaned_text
stringlengths
50
44.7k
tags
stringclasses
49 values
collection_name
stringclasses
11 values
0846a634-88bd-44aa-b21d-da3b28cdf2ce
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,091
supabase-export-v2
5495ecf58bed06aa
def __delitem__(self, key): for mapping in self.maps: if key in mapping: del mapping[key] return raise KeyError(key) >>> d = DeepChainMap({'zebra': 'black'}, {'elephant': 'blue'}, {'lion': 'yellow'}) >>> d['lion'] = 'orange' # update an existing key two levels down >>> d['snake'] = 'red' # new keys get added to the t...
trusted_official_docs
CPython Docs
def __delitem__(self, key): for mapping in self.maps: if key in mapping: del mapping[key] return raise KeyError(key) >>> d = DeepChainMap({'zebra': 'black'}, {'elephant': 'blue'}, {'lion': 'yellow'}) >>> d['lion'] = 'orange' # update an existing key two levels down >>> d['snake'] = 'red' # new keys get added to the t...
def __delitem__(self, key): for mapping in self.maps: if key in mapping: del mapping[key] return raise KeyError(key) >>> d = DeepChainMap({'zebra': 'black'}, {'elephant': 'blue'}, {'lion': 'yellow'}) >>> d['lion'] = 'orange' # update an existing key two levels down >>> d['snake'] = 'red' # new keys get added to the t...
python, official-docs, cpython, P0
Local_Trusted_Corpus
09fa4f17-a4ca-4a20-aabc-d2cf02f3c300
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,212
supabase-export-v2
719a311c72d007f0
implement :class:`deque` slicing and deletion. For example, a pure Python implementation of ``del d[n]`` relies on the ``rotate()`` method to position elements to be popped:: def delete_nth(d, n): d.rotate(-n) d.popleft() d.rotate(n)
trusted_official_docs
CPython Docs
implement :class:`deque` slicing and deletion. For example, a pure Python implementation of ``del d[n]`` relies on the ``rotate()`` method to position elements to be popped:: def delete_nth(d, n): d.rotate(-n) d.popleft() d.rotate(n)
implement :class:`deque` slicing and deletion. For example, a pure Python implementation of ``del d[n]`` relies on the ``rotate()`` method to position elements to be popped:: def delete_nth(d, n): d.rotate(-n) d.popleft() d.rotate(n)
python, official-docs, cpython, P0
Local_Trusted_Corpus
0d9fc616-1ee1-4606-b0ae-3f0445afb654
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,194
supabase-export-v2
49d981d727177f13
.. versionadded:: 3.1 In addition to the above, deques support iteration, pickling, ``len(d)``, ``reversed(d)``, ``copy.copy(d)``, ``copy.deepcopy(d)``, membership testing with the :keyword:`in` operator, and subscript references such as ``d[0]`` to access the first element. Indexed access is *O*\ (1) at both ends but ...
trusted_official_docs
CPython Docs
.. versionadded:: 3.1 In addition to the above, deques support iteration, pickling, ``len(d)``, ``reversed(d)``, ``copy.copy(d)``, ``copy.deepcopy(d)``, membership testing with the :keyword:`in` operator, and subscript references such as ``d[0]`` to access the first element. Indexed access is *O*\ (1) at both ends but ...
.. versionadded:: 3.1 In addition to the above, deques support iteration, pickling, ``len(d)``, ``reversed(d)``, ``copy.copy(d)``, ``copy.deepcopy(d)``, membership testing with the :keyword:`in` operator, and subscript references such as ``d[0]`` to access the first element. Indexed access is *O*\ (1) at both ends but ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
0dc88e57-5955-47cf-8b9f-2d7385f928a8
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,140
supabase-export-v2
2865d63b56f99127
no restrictions on its keys and values. The values are intended to be numbers representing counts, but you *could* store anything in the value field. * The :meth:`~Counter.most_common` method requires only that the values be orderable.
trusted_official_docs
CPython Docs
no restrictions on its keys and values. The values are intended to be numbers representing counts, but you *could* store anything in the value field. * The :meth:`~Counter.most_common` method requires only that the values be orderable.
no restrictions on its keys and values. The values are intended to be numbers representing counts, but you *could* store anything in the value field. * The :meth:`~Counter.most_common` method requires only that the values be orderable.
python, official-docs, cpython, P0
Local_Trusted_Corpus
12fefa2e-b246-4ee6-94b5-67864b1d7d65
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,349
supabase-export-v2
737e935003f2bc24
def __init__(self, func, maxsize=128, maxage=30): self.cache = OrderedDict() # { args : (timestamp, result)} self.func = func self.maxsize = maxsize self.maxage = maxage def __call__(self, *args): if args in self.cache: self.cache.move_to_end(args) timestamp, result = self.cache[args] if time() - timestamp <= self....
trusted_official_docs
CPython Docs
def __init__(self, func, maxsize=128, maxage=30): self.cache = OrderedDict() # { args : (timestamp, result)} self.func = func self.maxsize = maxsize self.maxage = maxage def __call__(self, *args): if args in self.cache: self.cache.move_to_end(args) timestamp, result = self.cache[args] if time() - timestamp <= self....
def __init__(self, func, maxsize=128, maxage=30): self.cache = OrderedDict() # { args : (timestamp, result)} self.func = func self.maxsize = maxsize self.maxage = maxage def __call__(self, *args): if args in self.cache: self.cache.move_to_end(args) timestamp, result = self.cache[args] if time() - timestamp <= self....
python, official-docs, cpython, P0
Local_Trusted_Corpus
16c106a3-1437-4b0f-935c-827929814884
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,157
supabase-export-v2
b8670c519756dc7e
``tail`` filter in Unix. They are also useful for tracking transactions and other pools of data where only the most recent activity is of interest. Deque objects support the following methods:
trusted_official_docs
CPython Docs
``tail`` filter in Unix. They are also useful for tracking transactions and other pools of data where only the most recent activity is of interest. Deque objects support the following methods:
``tail`` filter in Unix. They are also useful for tracking transactions and other pools of data where only the most recent activity is of interest. Deque objects support the following methods:
python, official-docs, cpython, P0
Local_Trusted_Corpus
1d9229d4-c66a-4810-926a-9d97f7745a96
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,200
supabase-export-v2
f6abcc8fa73b8e6c
list the contents of the deque ['g', 'h', 'i'] >>> d[0] # peek at leftmost item 'g' >>> d[-1] # peek at rightmost item 'i' >>> list(reversed(d)) # list the contents of a deque in reverse ['i', 'h', 'g'] >>> 'h' in d # search the deque True >>> d.extend('jkl') # add multiple elements at once >>> d deque(['g', 'h',...
trusted_official_docs
CPython Docs
list the contents of the deque ['g', 'h', 'i'] >>> d[0] # peek at leftmost item 'g' >>> d[-1] # peek at rightmost item 'i' >>> list(reversed(d)) # list the contents of a deque in reverse ['i', 'h', 'g'] >>> 'h' in d # search the deque True >>> d.extend('jkl') # add multiple elements at once >>> d deque(['g', 'h',...
list the contents of the deque ['g', 'h', 'i'] >>> d[0] # peek at leftmost item 'g' >>> d[-1] # peek at rightmost item 'i' >>> list(reversed(d)) # list the contents of a deque in reverse ['i', 'h', 'g'] >>> 'h' in d # search the deque True >>> d.extend('jkl') # add multiple elements at once >>> d deque(['g', 'h',...
python, official-docs, cpython, P0
Local_Trusted_Corpus
20243952-504c-4e28-b45e-beea6f14efa6
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,114
supabase-export-v2
ac212996eb3095e5
.. method:: subtract(**kwargs) subtract(iterable, /, **kwargs) subtract(mapping, /, **kwargs) Elements are subtracted from an *iterable* or from another *mapping* (or counter). Like :meth:`dict.update` but subtracts counts instead of replacing them. Both inputs and outputs may be zero or negative.
trusted_official_docs
CPython Docs
.. method:: subtract(**kwargs) subtract(iterable, /, **kwargs) subtract(mapping, /, **kwargs) Elements are subtracted from an *iterable* or from another *mapping* (or counter). Like :meth:`dict.update` but subtracts counts instead of replacing them. Both inputs and outputs may be zero or negative.
.. method:: subtract(**kwargs) subtract(iterable, /, **kwargs) subtract(mapping, /, **kwargs) Elements are subtracted from an *iterable* or from another *mapping* (or counter). Like :meth:`dict.update` but subtracts counts instead of replacing them. Both inputs and outputs may be zero or negative.
python, official-docs, cpython, P0
Local_Trusted_Corpus
24692509-2dd7-4c58-9215-1ec282007515
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,066
supabase-export-v2
8dcd255420d12b3e
Note, the iteration order of a :class:`ChainMap` is determined by scanning the mappings last to first:: >>> baseline = {'music': 'bach', 'art': 'rembrandt'} >>> adjustments = {'art': 'van gogh', 'opera': 'carmen'} >>> list(ChainMap(adjustments, baseline)) ['music', 'art', 'opera']
trusted_official_docs
CPython Docs
Note, the iteration order of a :class:`ChainMap` is determined by scanning the mappings last to first:: >>> baseline = {'music': 'bach', 'art': 'rembrandt'} >>> adjustments = {'art': 'van gogh', 'opera': 'carmen'} >>> list(ChainMap(adjustments, baseline)) ['music', 'art', 'opera']
Note, the iteration order of a :class:`ChainMap` is determined by scanning the mappings last to first:: >>> baseline = {'music': 'bach', 'art': 'rembrandt'} >>> adjustments = {'art': 'van gogh', 'opera': 'carmen'} >>> list(ChainMap(adjustments, baseline)) ['music', 'art', 'opera']
python, official-docs, cpython, P0
Local_Trusted_Corpus
24ebb235-569c-4d2b-9b89-f2a4d8f168b4
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,273
supabase-export-v2
6695e7859a586310
.. versionchanged:: 3.1 Returns an :class:`OrderedDict` instead of a regular :class:`dict`. .. versionchanged:: 3.8 Returns a regular :class:`dict` instead of an :class:`OrderedDict`. As of Python 3.7, regular dicts are guaranteed to be ordered. If the extra features of :class:`OrderedDict` are required, the suggeste...
trusted_official_docs
CPython Docs
.. versionchanged:: 3.1 Returns an :class:`OrderedDict` instead of a regular :class:`dict`. .. versionchanged:: 3.8 Returns a regular :class:`dict` instead of an :class:`OrderedDict`. As of Python 3.7, regular dicts are guaranteed to be ordered. If the extra features of :class:`OrderedDict` are required, the suggeste...
.. versionchanged:: 3.1 Returns an :class:`OrderedDict` instead of a regular :class:`dict`. .. versionchanged:: 3.8 Returns a regular :class:`dict` instead of an :class:`OrderedDict`. As of Python 3.7, regular dicts are guaranteed to be ordered. If the extra features of :class:`OrderedDict` are required, the suggeste...
python, official-docs, cpython, P0
Local_Trusted_Corpus
2a5637fb-fa8b-4a7a-9c04-37e5761bf350
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,148
supabase-export-v2
2431453aa4e76362
* `C++ multisets <http://www.java2s.com/Tutorial/Cpp/0380__set-multiset/Catalog0380__set-multiset.htm>`_ tutorial with examples. * For mathematical operations on multisets and their use cases, see *Knuth, Donald. The Art of Computer Programming Volume II, Section 4.6.3, Exercise 19*.
trusted_official_docs
CPython Docs
* `C++ multisets <http://www.java2s.com/Tutorial/Cpp/0380__set-multiset/Catalog0380__set-multiset.htm>`_ tutorial with examples. * For mathematical operations on multisets and their use cases, see *Knuth, Donald. The Art of Computer Programming Volume II, Section 4.6.3, Exercise 19*.
* `C++ multisets <http://www.java2s.com/Tutorial/Cpp/0380__set-multiset/Catalog0380__set-multiset.htm>`_ tutorial with examples. * For mathematical operations on multisets and their use cases, see *Knuth, Donald. The Art of Computer Programming Volume II, Section 4.6.3, Exercise 19*.
python, official-docs, cpython, P0
Local_Trusted_Corpus
2d3e5d82-e746-4b57-b317-782c72322467
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,367
supabase-export-v2
144bcadda6c22499
.. method:: popitem Remove and return a ``(key, value)`` pair from the wrapped dictionary. Pairs are returned in the same order as ``data.popitem()``. (For the default :meth:`dict.popitem`, this order is :abbr:`LIFO (last-in, first-out)`.) If the dictionary is empty, raises a :exc:`KeyError`.
trusted_official_docs
CPython Docs
.. method:: popitem Remove and return a ``(key, value)`` pair from the wrapped dictionary. Pairs are returned in the same order as ``data.popitem()``. (For the default :meth:`dict.popitem`, this order is :abbr:`LIFO (last-in, first-out)`.) If the dictionary is empty, raises a :exc:`KeyError`.
.. method:: popitem Remove and return a ``(key, value)`` pair from the wrapped dictionary. Pairs are returned in the same order as ``data.popitem()``. (For the default :meth:`dict.popitem`, this order is :abbr:`LIFO (last-in, first-out)`.) If the dictionary is empty, raises a :exc:`KeyError`.
python, official-docs, cpython, P0
Local_Trusted_Corpus
2d82660b-e387-4017-bce1-41706fbfa06e
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,143
supabase-export-v2
419361d5ef8eb47c
zero, but only outputs with positive values are created. There are no type restrictions, but the value type needs to support addition, subtraction, and comparison. * The :meth:`~Counter.elements` method requires integer counts. It ignores zero and negative counts.
trusted_official_docs
CPython Docs
zero, but only outputs with positive values are created. There are no type restrictions, but the value type needs to support addition, subtraction, and comparison. * The :meth:`~Counter.elements` method requires integer counts. It ignores zero and negative counts.
zero, but only outputs with positive values are created. There are no type restrictions, but the value type needs to support addition, subtraction, and comparison. * The :meth:`~Counter.elements` method requires integer counts. It ignores zero and negative counts.
python, official-docs, cpython, P0
Local_Trusted_Corpus
2dd800c9-d13e-4afb-b833-7cb2e8dc5fdb
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,322
supabase-export-v2
f390efd8b7f6adfc
regular :class:`dict` does not have an efficient equivalent for OrderedDict's ``od.move_to_end(k, last=False)`` which moves the key and its associated value to the leftmost (first) position. * Until Python 3.8, :class:`dict` lacked a :meth:`~object.__reversed__` method.
trusted_official_docs
CPython Docs
regular :class:`dict` does not have an efficient equivalent for OrderedDict's ``od.move_to_end(k, last=False)`` which moves the key and its associated value to the leftmost (first) position. * Until Python 3.8, :class:`dict` lacked a :meth:`~object.__reversed__` method.
regular :class:`dict` does not have an efficient equivalent for OrderedDict's ``od.move_to_end(k, last=False)`` which moves the key and its associated value to the leftmost (first) position. * Until Python 3.8, :class:`dict` lacked a :meth:`~object.__reversed__` method.
python, official-docs, cpython, P0
Local_Trusted_Corpus
2f4b18eb-3f78-4a4f-bea8-772a769210a9
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,099
supabase-export-v2
82440be19b492040
Elements are counted from an *iterable* or initialized from another *mapping* (or counter): >>> c = Counter() # a new, empty counter >>> c = Counter('gallahad') # a new counter from an iterable >>> c = Counter({'red': 4, 'blue': 2}) # a new counter from a mapping >>> c = Counter(cats=4, dogs=8) # a new counter from ...
trusted_official_docs
CPython Docs
Elements are counted from an *iterable* or initialized from another *mapping* (or counter): >>> c = Counter() # a new, empty counter >>> c = Counter('gallahad') # a new counter from an iterable >>> c = Counter({'red': 4, 'blue': 2}) # a new counter from a mapping >>> c = Counter(cats=4, dogs=8) # a new counter from ...
Elements are counted from an *iterable* or initialized from another *mapping* (or counter): >>> c = Counter() # a new, empty counter >>> c = Counter('gallahad') # a new counter from an iterable >>> c = Counter({'red': 4, 'blue': 2}) # a new counter from a mapping >>> c = Counter(cats=4, dogs=8) # a new counter from ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
346fbba6-42a1-4948-bdb3-5f43125b2154
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,251
supabase-export-v2
f5cb7afe6259d3ac
Named tuple instances do not have per-instance dictionaries, so they are lightweight and require no more memory than regular tuples. To support pickling, the named tuple class should be assigned to a variable that matches *typename*.
trusted_official_docs
CPython Docs
Named tuple instances do not have per-instance dictionaries, so they are lightweight and require no more memory than regular tuples. To support pickling, the named tuple class should be assigned to a variable that matches *typename*.
Named tuple instances do not have per-instance dictionaries, so they are lightweight and require no more memory than regular tuples. To support pickling, the named tuple class should be assigned to a variable that matches *typename*.
python, official-docs, cpython, P0
Local_Trusted_Corpus
354aa055-ed82-47c9-913c-a27ec30e59ae
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,293
supabase-export-v2
be6db766ecc34511
>>> d = {'x': 11, 'y': 22} >>> Point(**d) Point(x=11, y=22) Since a named tuple is a regular Python class, it is easy to add or change functionality with a subclass. Here is how to add a calculated field and a fixed-width print format:
trusted_official_docs
CPython Docs
>>> d = {'x': 11, 'y': 22} >>> Point(**d) Point(x=11, y=22) Since a named tuple is a regular Python class, it is easy to add or change functionality with a subclass. Here is how to add a calculated field and a fixed-width print format:
>>> d = {'x': 11, 'y': 22} >>> Point(**d) Point(x=11, y=22) Since a named tuple is a regular Python class, it is easy to add or change functionality with a subclass. Here is how to add a calculated field and a fixed-width print format:
python, official-docs, cpython, P0
Local_Trusted_Corpus
354e1b7c-6432-45e8-82b3-8448e845bd19
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,337
supabase-export-v2
37d2f1591e9117d8
between :class:`OrderedDict` objects and other :class:`~collections.abc.Mapping` objects are order-insensitive like regular dictionaries. This allows :class:`OrderedDict` objects to be substituted anywhere a regular dictionary is used. .. versionchanged:: 3.5 The items, keys, and values :term:`views <dictionary view>`...
trusted_official_docs
CPython Docs
between :class:`OrderedDict` objects and other :class:`~collections.abc.Mapping` objects are order-insensitive like regular dictionaries. This allows :class:`OrderedDict` objects to be substituted anywhere a regular dictionary is used. .. versionchanged:: 3.5 The items, keys, and values :term:`views <dictionary view>`...
between :class:`OrderedDict` objects and other :class:`~collections.abc.Mapping` objects are order-insensitive like regular dictionaries. This allows :class:`OrderedDict` objects to be substituted anywhere a regular dictionary is used. .. versionchanged:: 3.5 The items, keys, and values :term:`views <dictionary view>`...
python, official-docs, cpython, P0
Local_Trusted_Corpus
3a7974ca-d2cf-4020-85a6-e7b36a767d13
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,206
supabase-export-v2
5d48f86bef0ca505
Bounded length deques provide functionality similar to the ``tail`` filter in Unix:: def tail(filename, n=10): 'Return the last n lines of a file' with open(filename) as f: return deque(f, n)
trusted_official_docs
CPython Docs
Bounded length deques provide functionality similar to the ``tail`` filter in Unix:: def tail(filename, n=10): 'Return the last n lines of a file' with open(filename) as f: return deque(f, n)
Bounded length deques provide functionality similar to the ``tail`` filter in Unix:: def tail(filename, n=10): 'Return the last n lines of a file' with open(filename) as f: return deque(f, n)
python, official-docs, cpython, P0
Local_Trusted_Corpus
3b6c7d5c-c6a6-47b2-a3a9-b38985a0f5a1
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,244
supabase-export-v2
ced248d5a319b40b
.. function:: namedtuple(typename, field_names, *, rename=False, defaults=None, module=None) Returns a new tuple subclass named *typename*. The new subclass is used to create tuple-like objects that have fields accessible by attribute lookup as well as being indexable and iterable. Instances of the subclass also have...
trusted_official_docs
CPython Docs
.. function:: namedtuple(typename, field_names, *, rename=False, defaults=None, module=None) Returns a new tuple subclass named *typename*. The new subclass is used to create tuple-like objects that have fields accessible by attribute lookup as well as being indexable and iterable. Instances of the subclass also have...
.. function:: namedtuple(typename, field_names, *, rename=False, defaults=None, module=None) Returns a new tuple subclass named *typename*. The new subclass is used to create tuple-like objects that have fields accessible by attribute lookup as well as being indexable and iterable. Instances of the subclass also have...
python, official-docs, cpython, P0
Local_Trusted_Corpus
3bd434ca-c81c-445c-80a6-40de7b081abc
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,156
supabase-export-v2
9955a917c70105bf
and incur *O*\ (*n*) memory movement costs for ``pop(0)`` and ``insert(0, v)`` operations which change both the size and position of the underlying data representation. If *maxlen* is not specified or is ``None``, deques may grow to an arbitrary length. Otherwise, the deque is bounded to the specified maximum length....
trusted_official_docs
CPython Docs
and incur *O*\ (*n*) memory movement costs for ``pop(0)`` and ``insert(0, v)`` operations which change both the size and position of the underlying data representation. If *maxlen* is not specified or is ``None``, deques may grow to an arbitrary length. Otherwise, the deque is bounded to the specified maximum length....
and incur *O*\ (*n*) memory movement costs for ``pop(0)`` and ``insert(0, v)`` operations which change both the size and position of the underlying data representation. If *maxlen* is not specified or is ``None``, deques may grow to an arbitrary length. Otherwise, the deque is bounded to the specified maximum length....
python, official-docs, cpython, P0
Local_Trusted_Corpus
3c113dfe-a157-4596-9004-2d1e42157771
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,125
supabase-export-v2
434282aae60a6467
but adds counts instead of replacing them. Also, the *iterable* is expected to be a sequence of elements, not a sequence of ``(key, value)`` pairs. Counters support rich comparison operators for equality, subset, and superset relationships: ``==``, ``!=``, ``<``, ``<=``, ``>``, ``>=``. All of those tests treat missing ...
trusted_official_docs
CPython Docs
but adds counts instead of replacing them. Also, the *iterable* is expected to be a sequence of elements, not a sequence of ``(key, value)`` pairs. Counters support rich comparison operators for equality, subset, and superset relationships: ``==``, ``!=``, ``<``, ``<=``, ``>``, ``>=``. All of those tests treat missing ...
but adds counts instead of replacing them. Also, the *iterable* is expected to be a sequence of elements, not a sequence of ``(key, value)`` pairs. Counters support rich comparison operators for equality, subset, and superset relationships: ``==``, ``!=``, ``<``, ``<=``, ``>``, ``>=``. All of those tests treat missing ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
3c4010a7-f55a-4937-9d24-f0ad532cbaf8
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,124
supabase-export-v2
42d5360ad7a74349
.. method:: update(**kwargs) update(iterable, /, **kwargs) update(mapping, /, **kwargs) Elements are counted from an *iterable* or added-in from another *mapping* (or counter). Like :meth:`dict.update` but adds counts instead of replacing them. Also, the *iterable* is expected to be a sequence of elements, not a seq...
trusted_official_docs
CPython Docs
.. method:: update(**kwargs) update(iterable, /, **kwargs) update(mapping, /, **kwargs) Elements are counted from an *iterable* or added-in from another *mapping* (or counter). Like :meth:`dict.update` but adds counts instead of replacing them. Also, the *iterable* is expected to be a sequence of elements, not a seq...
.. method:: update(**kwargs) update(iterable, /, **kwargs) update(mapping, /, **kwargs) Elements are counted from an *iterable* or added-in from another *mapping* (or counter). Like :meth:`dict.update` but adds counts instead of replacing them. Also, the *iterable* is expected to be a sequence of elements, not a seq...
python, official-docs, cpython, P0
Local_Trusted_Corpus
3f6cdcd1-ea70-4254-bfc1-4dd4c352f60e
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,314
supabase-export-v2
2a5f2e7dd4e6fb20
can handle frequent reordering operations better than :class:`dict`. As shown in the recipes below, this makes it suitable for implementing various kinds of LRU caches. * The equality operation for :class:`OrderedDict` checks for matching order.
trusted_official_docs
CPython Docs
can handle frequent reordering operations better than :class:`dict`. As shown in the recipes below, this makes it suitable for implementing various kinds of LRU caches. * The equality operation for :class:`OrderedDict` checks for matching order.
can handle frequent reordering operations better than :class:`dict`. As shown in the recipes below, this makes it suitable for implementing various kinds of LRU caches. * The equality operation for :class:`OrderedDict` checks for matching order.
python, official-docs, cpython, P0
Local_Trusted_Corpus
402997f0-b42d-4657-94f3-285e063b3687
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,052
supabase-export-v2
d1421174f6551de9
.. class:: ChainMap(*maps) A :class:`ChainMap` groups multiple dicts or other mappings together to create a single, updateable view. If no *maps* are specified, a single empty dictionary is provided so that a new chain always has at least one mapping.
trusted_official_docs
CPython Docs
.. class:: ChainMap(*maps) A :class:`ChainMap` groups multiple dicts or other mappings together to create a single, updateable view. If no *maps* are specified, a single empty dictionary is provided so that a new chain always has at least one mapping.
.. class:: ChainMap(*maps) A :class:`ChainMap` groups multiple dicts or other mappings together to create a single, updateable view. If no *maps* are specified, a single empty dictionary is provided so that a new chain always has at least one mapping.
python, official-docs, cpython, P0
Local_Trusted_Corpus
410584e6-eee8-4362-bbac-f1f59ba1fb09
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,316
supabase-export-v2
eb8aa7a3d4fbb050
A regular :class:`dict` can emulate the order sensitive equality test with ``p == q and all(k1 == k2 for k1, k2 in zip(p, q))``. * The :meth:`~OrderedDict.popitem` method of :class:`OrderedDict` has a different signature. It accepts an optional argument to specify which item is popped.
trusted_official_docs
CPython Docs
A regular :class:`dict` can emulate the order sensitive equality test with ``p == q and all(k1 == k2 for k1, k2 in zip(p, q))``. * The :meth:`~OrderedDict.popitem` method of :class:`OrderedDict` has a different signature. It accepts an optional argument to specify which item is popped.
A regular :class:`dict` can emulate the order sensitive equality test with ``p == q and all(k1 == k2 for k1, k2 in zip(p, q))``. * The :meth:`~OrderedDict.popitem` method of :class:`OrderedDict` has a different signature. It accepts an optional argument to specify which item is popped.
python, official-docs, cpython, P0
Local_Trusted_Corpus
41b2e5ed-e73c-46c7-8049-892835343901
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,046
supabase-export-v2
27fb7794180e7f67
This module implements specialized container datatypes providing alternatives to Python's general purpose built-in containers, :class:`dict`, :class:`list`, :class:`set`, and :class:`tuple`. ===================== ==================================================================== :func:`namedtuple` factory function fo...
trusted_official_docs
CPython Docs
This module implements specialized container datatypes providing alternatives to Python's general purpose built-in containers, :class:`dict`, :class:`list`, :class:`set`, and :class:`tuple`. ===================== ==================================================================== :func:`namedtuple` factory function fo...
This module implements specialized container datatypes providing alternatives to Python's general purpose built-in containers, :class:`dict`, :class:`list`, :class:`set`, and :class:`tuple`. ===================== ==================================================================== :func:`namedtuple` factory function fo...
python, official-docs, cpython, P0
Local_Trusted_Corpus
422aa1b6-742d-4e9e-91bf-aeff6f24ca1f
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,095
supabase-export-v2
3b94aabfe9c5a8b6
= Counter() >>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']: ... cnt[word] += 1 ... >>> cnt Counter({'blue': 3, 'red': 2, 'green': 1}) >>> # Find the ten most common words in Hamlet >>> import re >>> words = re.findall(r'\w+', open('hamlet.txt').read().lower()) >>> Counter(words).most_common(10) [('...
trusted_official_docs
CPython Docs
= Counter() >>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']: ... cnt[word] += 1 ... >>> cnt Counter({'blue': 3, 'red': 2, 'green': 1}) >>> # Find the ten most common words in Hamlet >>> import re >>> words = re.findall(r'\w+', open('hamlet.txt').read().lower()) >>> Counter(words).most_common(10) [('...
= Counter() >>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']: ... cnt[word] += 1 ... >>> cnt Counter({'blue': 3, 'red': 2, 'green': 1}) >>> # Find the ten most common words in Hamlet >>> import re >>> words = re.findall(r'\w+', open('hamlet.txt').read().lower()) >>> Counter(words).most_common(10) [('...
python, official-docs, cpython, P0
Local_Trusted_Corpus
42e8faea-2fe0-40e3-97ad-d0d492480210
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,073
supabase-export-v2
6163d81301e6ce8f
for templating is a read-only chain of mappings. It also features pushing and popping of contexts similar to the :meth:`~collections.ChainMap.new_child` method and the :attr:`~collections.ChainMap.parents` property. * The `Nested Contexts recipe <https://code.activestate.com/recipes/577434-nested-contexts-a-chain-of-m...
trusted_official_docs
CPython Docs
for templating is a read-only chain of mappings. It also features pushing and popping of contexts similar to the :meth:`~collections.ChainMap.new_child` method and the :attr:`~collections.ChainMap.parents` property. * The `Nested Contexts recipe <https://code.activestate.com/recipes/577434-nested-contexts-a-chain-of-m...
for templating is a read-only chain of mappings. It also features pushing and popping of contexts similar to the :meth:`~collections.ChainMap.new_child` method and the :attr:`~collections.ChainMap.parents` property. * The `Nested Contexts recipe <https://code.activestate.com/recipes/577434-nested-contexts-a-chain-of-m...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4300289d-6f15-4c0d-b294-2ab151022288
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,127
supabase-export-v2
79580008871d1f47
.. versionchanged:: 3.10 Rich comparison operations were added. .. versionchanged:: 3.10 In equality tests, missing elements are treated as having zero counts. Formerly, ``Counter(a=3)`` and ``Counter(a=3, b=0)`` were considered distinct.
trusted_official_docs
CPython Docs
.. versionchanged:: 3.10 Rich comparison operations were added. .. versionchanged:: 3.10 In equality tests, missing elements are treated as having zero counts. Formerly, ``Counter(a=3)`` and ``Counter(a=3, b=0)`` were considered distinct.
.. versionchanged:: 3.10 Rich comparison operations were added. .. versionchanged:: 3.10 In equality tests, missing elements are treated as having zero counts. Formerly, ``Counter(a=3)`` and ``Counter(a=3, b=0)`` were considered distinct.
python, official-docs, cpython, P0
Local_Trusted_Corpus
445708a0-b59f-4239-9376-0cf4e8896c25
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,216
supabase-export-v2
e376baeb0f822b83
.. class:: defaultdict(default_factory=None, /, **kwargs) defaultdict(default_factory, mapping, /, **kwargs) defaultdict(default_factory, iterable, /, **kwargs) Return a new dictionary-like object. :class:`defaultdict` is a subclass of the built-in :class:`dict` class. It overrides one method and adds one writable in...
trusted_official_docs
CPython Docs
.. class:: defaultdict(default_factory=None, /, **kwargs) defaultdict(default_factory, mapping, /, **kwargs) defaultdict(default_factory, iterable, /, **kwargs) Return a new dictionary-like object. :class:`defaultdict` is a subclass of the built-in :class:`dict` class. It overrides one method and adds one writable in...
.. class:: defaultdict(default_factory=None, /, **kwargs) defaultdict(default_factory, mapping, /, **kwargs) defaultdict(default_factory, iterable, /, **kwargs) Return a new dictionary-like object. :class:`defaultdict` is a subclass of the built-in :class:`dict` class. It overrides one method and adds one writable in...
python, official-docs, cpython, P0
Local_Trusted_Corpus
451159d0-b444-4683-aa37-46e216d5fb2f
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,105
supabase-export-v2
6904bae2c50ac854
.. versionadded:: 3.1 .. versionchanged:: 3.7 As a :class:`dict` subclass, :class:`Counter` inherited the capability to remember insertion order. Math operations on *Counter* objects also preserve order. Results are ordered according to when an element is first encountered in the left operand and then by the order ...
trusted_official_docs
CPython Docs
.. versionadded:: 3.1 .. versionchanged:: 3.7 As a :class:`dict` subclass, :class:`Counter` inherited the capability to remember insertion order. Math operations on *Counter* objects also preserve order. Results are ordered according to when an element is first encountered in the left operand and then by the order ...
.. versionadded:: 3.1 .. versionchanged:: 3.7 As a :class:`dict` subclass, :class:`Counter` inherited the capability to remember insertion order. Math operations on *Counter* objects also preserve order. Results are ordered according to when an element is first encountered in the left operand and then by the order ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
45540f25-2c0f-4607-8a91-7ac6d55901cb
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,241
supabase-export-v2
f6e4b2217bd4e95c
('red', 1), ('blue', 4)] >>> d = defaultdict(set) >>> for k, v in s: ... d[k].add(v) ... >>> sorted(d.items()) [('blue', {2, 4}), ('red', {1, 3})] :func:`namedtuple` Factory Function for Tuples with Named Fields ----------------------------------------------------------------
trusted_official_docs
CPython Docs
('red', 1), ('blue', 4)] >>> d = defaultdict(set) >>> for k, v in s: ... d[k].add(v) ... >>> sorted(d.items()) [('blue', {2, 4}), ('red', {1, 3})] :func:`namedtuple` Factory Function for Tuples with Named Fields ----------------------------------------------------------------
('red', 1), ('blue', 4)] >>> d = defaultdict(set) >>> for k, v in s: ... d[k].add(v) ... >>> sorted(d.items()) [('blue', {2, 4}), ('red', {1, 3})] :func:`namedtuple` Factory Function for Tuples with Named Fields ----------------------------------------------------------------
python, official-docs, cpython, P0
Local_Trusted_Corpus
45f5b2f6-f226-4c8b-aa38-acbf986017a4
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,321
supabase-export-v2
03a747d56252c25d
regular :class:`dict` can emulate OrderedDict's ``od.move_to_end(k, last=True)`` with ``d[k] = d.pop(k)`` which will move the key and its associated value to the rightmost (last) position. A regular :class:`dict` does not have an efficient equivalent for OrderedDict's ``od.move_to_end(k, last=False)`` which moves the ...
trusted_official_docs
CPython Docs
regular :class:`dict` can emulate OrderedDict's ``od.move_to_end(k, last=True)`` with ``d[k] = d.pop(k)`` which will move the key and its associated value to the rightmost (last) position. A regular :class:`dict` does not have an efficient equivalent for OrderedDict's ``od.move_to_end(k, last=False)`` which moves the ...
regular :class:`dict` can emulate OrderedDict's ``od.move_to_end(k, last=True)`` with ``d[k] = d.pop(k)`` which will move the key and its associated value to the rightmost (last) position. A regular :class:`dict` does not have an efficient equivalent for OrderedDict's ``od.move_to_end(k, last=False)`` which moves the ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
46f3ef09-8e0c-48ea-9fbf-2fb6ad75c765
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,111
supabase-export-v2
456dfdb9bd070fce
.. method:: most_common(n=None) Return a list of the *n* most common elements and their counts from the most common to the least. If *n* is omitted or ``None``, :meth:`most_common` returns *all* elements in the counter. Elements with equal counts are ordered in the order first encountered:
trusted_official_docs
CPython Docs
.. method:: most_common(n=None) Return a list of the *n* most common elements and their counts from the most common to the least. If *n* is omitted or ``None``, :meth:`most_common` returns *all* elements in the counter. Elements with equal counts are ordered in the order first encountered:
.. method:: most_common(n=None) Return a list of the *n* most common elements and their counts from the most common to the least. If *n* is omitted or ``None``, :meth:`most_common` returns *all* elements in the counter. Elements with equal counts are ordered in the order first encountered:
python, official-docs, cpython, P0
Local_Trusted_Corpus
484212c8-154f-46e0-8872-964bf756004a
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,115
supabase-export-v2
2c64fa295ef9c877
*iterable* or from another *mapping* (or counter). Like :meth:`dict.update` but subtracts counts instead of replacing them. Both inputs and outputs may be zero or negative. >>> c = Counter(a=4, b=2, c=0, d=-2) >>> d = Counter(a=1, b=2, c=3, d=4) >>> c.subtract(d) >>> c Counter({'a': 3, 'b': 0, 'c': -3, 'd': -6})
trusted_official_docs
CPython Docs
*iterable* or from another *mapping* (or counter). Like :meth:`dict.update` but subtracts counts instead of replacing them. Both inputs and outputs may be zero or negative. >>> c = Counter(a=4, b=2, c=0, d=-2) >>> d = Counter(a=1, b=2, c=3, d=4) >>> c.subtract(d) >>> c Counter({'a': 3, 'b': 0, 'c': -3, 'd': -6})
*iterable* or from another *mapping* (or counter). Like :meth:`dict.update` but subtracts counts instead of replacing them. Both inputs and outputs may be zero or negative. >>> c = Counter(a=4, b=2, c=0, d=-2) >>> d = Counter(a=1, b=2, c=3, d=4) >>> c.subtract(d) >>> c Counter({'a': 3, 'b': 0, 'c': -3, 'd': -6})
python, official-docs, cpython, P0
Local_Trusted_Corpus
4ae45363-b6cf-4ee3-a13d-d0cc7532531c
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,338
supabase-export-v2
889dd1a987d55412
.. versionchanged:: 3.5 The items, keys, and values :term:`views <dictionary view>` of :class:`OrderedDict` now support reverse iteration using :func:`reversed`. .. versionchanged:: 3.6 With the acceptance of :pep:`468`, order is retained for keyword arguments passed to the :class:`OrderedDict` constructor and its :m...
trusted_official_docs
CPython Docs
.. versionchanged:: 3.5 The items, keys, and values :term:`views <dictionary view>` of :class:`OrderedDict` now support reverse iteration using :func:`reversed`. .. versionchanged:: 3.6 With the acceptance of :pep:`468`, order is retained for keyword arguments passed to the :class:`OrderedDict` constructor and its :m...
.. versionchanged:: 3.5 The items, keys, and values :term:`views <dictionary view>` of :class:`OrderedDict` now support reverse iteration using :func:`reversed`. .. versionchanged:: 3.6 With the acceptance of :pep:`468`, order is retained for keyword arguments passed to the :class:`OrderedDict` constructor and its :m...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4b595c52-368e-46ea-b102-07001b7106e7
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,112
supabase-export-v2
c42d4c40b93e74f8
least. If *n* is omitted or ``None``, :meth:`most_common` returns *all* elements in the counter. Elements with equal counts are ordered in the order first encountered: >>> Counter('abracadabra').most_common(3) [('a', 5), ('b', 2), ('r', 2)]
trusted_official_docs
CPython Docs
least. If *n* is omitted or ``None``, :meth:`most_common` returns *all* elements in the counter. Elements with equal counts are ordered in the order first encountered: >>> Counter('abracadabra').most_common(3) [('a', 5), ('b', 2), ('r', 2)]
least. If *n* is omitted or ``None``, :meth:`most_common` returns *all* elements in the counter. Elements with equal counts are ordered in the order first encountered: >>> Counter('abracadabra').most_common(3) [('a', 5), ('b', 2), ('r', 2)]
python, official-docs, cpython, P0
Local_Trusted_Corpus
4d2ef331-2b08-4701-b935-863a48810a0e
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,225
supabase-export-v2
972f75be28b417d5
is *not* called for any operations besides :meth:`~object.__getitem__`. This means that :meth:`~dict.get` will, like normal dictionaries, return ``None`` as a default rather than using :attr:`default_factory`. :class:`defaultdict` objects support the following instance variable:
trusted_official_docs
CPython Docs
is *not* called for any operations besides :meth:`~object.__getitem__`. This means that :meth:`~dict.get` will, like normal dictionaries, return ``None`` as a default rather than using :attr:`default_factory`. :class:`defaultdict` objects support the following instance variable:
is *not* called for any operations besides :meth:`~object.__getitem__`. This means that :meth:`~dict.get` will, like normal dictionaries, return ``None`` as a default rather than using :attr:`default_factory`. :class:`defaultdict` objects support the following instance variable:
python, official-docs, cpython, P0
Local_Trusted_Corpus
4d7578bc-ffaa-47c0-a454-bc8a13209e0a
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,134
supabase-export-v2
2ab5c009ccf48c19
Unary addition and subtraction are shortcuts for adding an empty counter or subtracting from an empty counter. >>> c = Counter(a=2, b=-4) >>> +c Counter({'a': 2}) >>> -c Counter({'b': 4})
trusted_official_docs
CPython Docs
Unary addition and subtraction are shortcuts for adding an empty counter or subtracting from an empty counter. >>> c = Counter(a=2, b=-4) >>> +c Counter({'a': 2}) >>> -c Counter({'b': 4})
Unary addition and subtraction are shortcuts for adding an empty counter or subtracting from an empty counter. >>> c = Counter(a=2, b=-4) >>> +c Counter({'a': 2}) >>> -c Counter({'b': 4})
python, official-docs, cpython, P0
Local_Trusted_Corpus
50489cc8-ebab-40b9-892a-080286706116
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,377
supabase-export-v2
7abb3ee84097ff0e
To do so, it assumes that the constructor can be called with a single parameter, which is a sequence object used as a data source. If a derived class does not wish to comply with this requirement, all of the special methods supported by this class will need to be overridden; please consult the sources for information a...
trusted_official_docs
CPython Docs
To do so, it assumes that the constructor can be called with a single parameter, which is a sequence object used as a data source. If a derived class does not wish to comply with this requirement, all of the special methods supported by this class will need to be overridden; please consult the sources for information a...
To do so, it assumes that the constructor can be called with a single parameter, which is a sequence object used as a data source. If a derived class does not wish to comply with this requirement, all of the special methods supported by this class will need to be overridden; please consult the sources for information a...
python, official-docs, cpython, P0
Local_Trusted_Corpus
51fe9ad3-0a06-43c6-88c5-6abb5d5d6041
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,090
supabase-export-v2
d24cf1f6964e6f7e
def __setitem__(self, key, value): for mapping in self.maps: if key in mapping: mapping[key] = value return self.maps[0][key] = value def __delitem__(self, key): for mapping in self.maps: if key in mapping: del mapping[key] return raise KeyError(key)
trusted_official_docs
CPython Docs
def __setitem__(self, key, value): for mapping in self.maps: if key in mapping: mapping[key] = value return self.maps[0][key] = value def __delitem__(self, key): for mapping in self.maps: if key in mapping: del mapping[key] return raise KeyError(key)
def __setitem__(self, key, value): for mapping in self.maps: if key in mapping: mapping[key] = value return self.maps[0][key] = value def __delitem__(self, key): for mapping in self.maps: if key in mapping: del mapping[key] return raise KeyError(key)
python, official-docs, cpython, P0
Local_Trusted_Corpus
522aff6b-5e5a-4b68-96f0-78e682e75e5d
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,133
supabase-export-v2
2862e1ca24437ebc
d[x]) Counter({'a': 2, 'b': 1}) >>> c == d # equality: c[x] == d[x] False >>> c <= d # inclusion: c[x] <= d[x] False Unary addition and subtraction are shortcuts for adding an empty counter or subtracting from an empty counter.
trusted_official_docs
CPython Docs
d[x]) Counter({'a': 2, 'b': 1}) >>> c == d # equality: c[x] == d[x] False >>> c <= d # inclusion: c[x] <= d[x] False Unary addition and subtraction are shortcuts for adding an empty counter or subtracting from an empty counter.
d[x]) Counter({'a': 2, 'b': 1}) >>> c == d # equality: c[x] == d[x] False >>> c <= d # inclusion: c[x] <= d[x] False Unary addition and subtraction are shortcuts for adding an empty counter or subtracting from an empty counter.
python, official-docs, cpython, P0
Local_Trusted_Corpus
528fd9b1-6abc-4e95-b528-6c589bb3cecf
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,263
supabase-export-v2
91835f8092a4966f
import sqlite3 conn = sqlite3.connect('/companydata') cursor = conn.cursor() cursor.execute('SELECT name, age, title, department, paygrade FROM employees') for emp in map(EmployeeRecord._make, cursor.fetchall()): print(emp.name, emp.title) In addition to the methods inherited from tuples, named tuples support three add...
trusted_official_docs
CPython Docs
import sqlite3 conn = sqlite3.connect('/companydata') cursor = conn.cursor() cursor.execute('SELECT name, age, title, department, paygrade FROM employees') for emp in map(EmployeeRecord._make, cursor.fetchall()): print(emp.name, emp.title) In addition to the methods inherited from tuples, named tuples support three add...
import sqlite3 conn = sqlite3.connect('/companydata') cursor = conn.cursor() cursor.execute('SELECT name, age, title, department, paygrade FROM employees') for emp in map(EmployeeRecord._make, cursor.fetchall()): print(emp.name, emp.title) In addition to the methods inherited from tuples, named tuples support three add...
python, official-docs, cpython, P0
Local_Trusted_Corpus
52bac0e2-6c9b-45cb-b2ea-2cca368dbb11
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,222
supabase-export-v2
b71ff7d5f0a8de0e
is called without arguments to provide a default value for the given *key*, this value is inserted in the dictionary for the *key*, and returned. If calling :attr:`default_factory` raises an exception this exception is propagated unchanged.
trusted_official_docs
CPython Docs
is called without arguments to provide a default value for the given *key*, this value is inserted in the dictionary for the *key*, and returned. If calling :attr:`default_factory` raises an exception this exception is propagated unchanged.
is called without arguments to provide a default value for the given *key*, this value is inserted in the dictionary for the *key*, and returned. If calling :attr:`default_factory` raises an exception this exception is propagated unchanged.
python, official-docs, cpython, P0
Local_Trusted_Corpus
52c1ad18-470c-4cf0-a729-1df6305f01c4
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,074
supabase-export-v2
4e6ad987d7373642
Contexts recipe <https://code.activestate.com/recipes/577434-nested-contexts-a-chain-of-mapping-objects/>`_ has options to control whether writes and other mutations apply only to the first mapping or to any mapping in the chain. * A `greatly simplified read-only version of Chainmap <https://code.activestate.com/recip...
trusted_official_docs
CPython Docs
Contexts recipe <https://code.activestate.com/recipes/577434-nested-contexts-a-chain-of-mapping-objects/>`_ has options to control whether writes and other mutations apply only to the first mapping or to any mapping in the chain. * A `greatly simplified read-only version of Chainmap <https://code.activestate.com/recip...
Contexts recipe <https://code.activestate.com/recipes/577434-nested-contexts-a-chain-of-mapping-objects/>`_ has options to control whether writes and other mutations apply only to the first mapping or to any mapping in the chain. * A `greatly simplified read-only version of Chainmap <https://code.activestate.com/recip...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5405c3c5-66de-494f-81a9-3332caf5d51d
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,126
supabase-export-v2
cf70e7c9f20acff5
``==``, ``!=``, ``<``, ``<=``, ``>``, ``>=``. All of those tests treat missing elements as having zero counts so that ``Counter(a=1) == Counter(a=1, b=0)`` returns true. .. versionchanged:: 3.10 Rich comparison operations were added.
trusted_official_docs
CPython Docs
``==``, ``!=``, ``<``, ``<=``, ``>``, ``>=``. All of those tests treat missing elements as having zero counts so that ``Counter(a=1) == Counter(a=1, b=0)`` returns true. .. versionchanged:: 3.10 Rich comparison operations were added.
``==``, ``!=``, ``<``, ``<=``, ``>``, ``>=``. All of those tests treat missing elements as having zero counts so that ``Counter(a=1) == Counter(a=1, b=0)`` returns true. .. versionchanged:: 3.10 Rich comparison operations were added.
python, official-docs, cpython, P0
Local_Trusted_Corpus
54c4fad6-8693-4ee6-a510-7e72fc6f62f5
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,317
supabase-export-v2
5f55bc8194036b99
* The :meth:`~OrderedDict.popitem` method of :class:`OrderedDict` has a different signature. It accepts an optional argument to specify which item is popped. A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=True)`` with ``d.popitem()`` which is guaranteed to pop the rightmost (last) item.
trusted_official_docs
CPython Docs
* The :meth:`~OrderedDict.popitem` method of :class:`OrderedDict` has a different signature. It accepts an optional argument to specify which item is popped. A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=True)`` with ``d.popitem()`` which is guaranteed to pop the rightmost (last) item.
* The :meth:`~OrderedDict.popitem` method of :class:`OrderedDict` has a different signature. It accepts an optional argument to specify which item is popped. A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=True)`` with ``d.popitem()`` which is guaranteed to pop the rightmost (last) item.
python, official-docs, cpython, P0
Local_Trusted_Corpus
55644fcb-917d-44b6-beb7-afc4ba171f96
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,085
supabase-export-v2
5fe933c806cd30c6
Example patterns for using the :class:`ChainMap` class to simulate nested contexts:: c = ChainMap() # Create root context d = c.new_child() # Create nested child context e = c.new_child() # Child of c, independent from d e.maps[0] # Current context dictionary -- like Python's locals() e.maps[-1] # Root context -- l...
trusted_official_docs
CPython Docs
Example patterns for using the :class:`ChainMap` class to simulate nested contexts:: c = ChainMap() # Create root context d = c.new_child() # Create nested child context e = c.new_child() # Child of c, independent from d e.maps[0] # Current context dictionary -- like Python's locals() e.maps[-1] # Root context -- l...
Example patterns for using the :class:`ChainMap` class to simulate nested contexts:: c = ChainMap() # Create root context d = c.new_child() # Create nested child context e = c.new_child() # Child of c, independent from d e.maps[0] # Current context dictionary -- like Python's locals() e.maps[-1] # Root context -- l...
python, official-docs, cpython, P0
Local_Trusted_Corpus
573fcc02-f0cf-4095-aab9-fed28f9b40d1
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,355
supabase-export-v2
85c485b4b6c27d47
self.func = func self.maxrequests = maxrequests # max number of uncached requests self.maxsize = maxsize # max number of stored return values self.cache_after = cache_after def __call__(self, *args): if args in self.cache: self.cache.move_to_end(args) return self.cache[args] result = self.func(*args) self.requests...
trusted_official_docs
CPython Docs
self.func = func self.maxrequests = maxrequests # max number of uncached requests self.maxsize = maxsize # max number of stored return values self.cache_after = cache_after def __call__(self, *args): if args in self.cache: self.cache.move_to_end(args) return self.cache[args] result = self.func(*args) self.requests...
self.func = func self.maxrequests = maxrequests # max number of uncached requests self.maxsize = maxsize # max number of stored return values self.cache_after = cache_after def __call__(self, *args): if args in self.cache: self.cache.move_to_end(args) return self.cache[args] result = self.func(*args) self.requests...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5c9fc88b-a0d9-4cbe-b6b4-04d331c20faa
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,154
supabase-export-v2
a01af104b380506c
Returns a new deque object initialized left-to-right (using :meth:`append`) with data from *iterable*. If *iterable* is not specified, the new deque is empty. Deques are a generalization of stacks and queues (the name is pronounced "deck" and is short for "double-ended queue"). Deques support thread-safe, memory effi...
trusted_official_docs
CPython Docs
Returns a new deque object initialized left-to-right (using :meth:`append`) with data from *iterable*. If *iterable* is not specified, the new deque is empty. Deques are a generalization of stacks and queues (the name is pronounced "deck" and is short for "double-ended queue"). Deques support thread-safe, memory effi...
Returns a new deque object initialized left-to-right (using :meth:`append`) with data from *iterable*. If *iterable* is not specified, the new deque is empty. Deques are a generalization of stacks and queues (the name is pronounced "deck" and is short for "double-ended queue"). Deques support thread-safe, memory effi...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5cd69270-8347-44e3-a943-07bc0e876a80
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,202
supabase-export-v2
25123a6d064c878d
# cannot pop from an empty deque Traceback (most recent call last): File "<pyshell#6>", line 1, in -toplevel- d.pop() IndexError: pop from an empty deque >>> d.extendleft('abc') # extendleft() reverses the input order >>> d deque(['c', 'b', 'a'])
trusted_official_docs
CPython Docs
# cannot pop from an empty deque Traceback (most recent call last): File "<pyshell#6>", line 1, in -toplevel- d.pop() IndexError: pop from an empty deque >>> d.extendleft('abc') # extendleft() reverses the input order >>> d deque(['c', 'b', 'a'])
# cannot pop from an empty deque Traceback (most recent call last): File "<pyshell#6>", line 1, in -toplevel- d.pop() IndexError: pop from an empty deque >>> d.extendleft('abc') # extendleft() reverses the input order >>> d deque(['c', 'b', 'a'])
python, official-docs, cpython, P0
Local_Trusted_Corpus
5d9684c7-c5c9-4435-91b6-f7538488422a
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,258
supabase-export-v2
8c81831e0b9e6be5
.. doctest:: :options: +NORMALIZE_WHITESPACE >>> # Basic example >>> Point = namedtuple('Point', ['x', 'y']) >>> p = Point(11, y=22) # instantiate with positional or keyword arguments >>> p[0] + p[1] # indexable like the plain tuple (11, 22) 33 >>> x, y = p # unpack like a regular tuple >>> x, y (11, 22) >>> p....
trusted_official_docs
CPython Docs
.. doctest:: :options: +NORMALIZE_WHITESPACE >>> # Basic example >>> Point = namedtuple('Point', ['x', 'y']) >>> p = Point(11, y=22) # instantiate with positional or keyword arguments >>> p[0] + p[1] # indexable like the plain tuple (11, 22) 33 >>> x, y = p # unpack like a regular tuple >>> x, y (11, 22) >>> p....
.. doctest:: :options: +NORMALIZE_WHITESPACE >>> # Basic example >>> Point = namedtuple('Point', ['x', 'y']) >>> p = Point(11, y=22) # instantiate with positional or keyword arguments >>> p[0] + p[1] # indexable like the plain tuple (11, 22) 33 >>> x, y = p # unpack like a regular tuple >>> x, y (11, 22) >>> p....
python, official-docs, cpython, P0
Local_Trusted_Corpus
5db7f05a-7c14-48d2-8a05-efec587ce07a
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,242
supabase-export-v2
cd5c87bb37abe069
:func:`namedtuple` Factory Function for Tuples with Named Fields ---------------------------------------------------------------- Named tuples assign meaning to each position in a tuple and allow for more readable, self-documenting code. They can be used wherever regular tuples are used, and they add the ability to acc...
trusted_official_docs
CPython Docs
:func:`namedtuple` Factory Function for Tuples with Named Fields ---------------------------------------------------------------- Named tuples assign meaning to each position in a tuple and allow for more readable, self-documenting code. They can be used wherever regular tuples are used, and they add the ability to acc...
:func:`namedtuple` Factory Function for Tuples with Named Fields ---------------------------------------------------------------- Named tuples assign meaning to each position in a tuple and allow for more readable, self-documenting code. They can be used wherever regular tuples are used, and they add the ability to acc...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5e7f4e17-4060-4332-acd4-1f5d3fc13b16
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,174
supabase-export-v2
8f95391231596825
.. method:: index(value[, start[, stop]]) Return the position of *value* in the deque (at or after index *start* and before index *stop*). Returns the first match or raises :exc:`ValueError` if not found.
trusted_official_docs
CPython Docs
.. method:: index(value[, start[, stop]]) Return the position of *value* in the deque (at or after index *start* and before index *stop*). Returns the first match or raises :exc:`ValueError` if not found.
.. method:: index(value[, start[, stop]]) Return the position of *value* in the deque (at or after index *start* and before index *stop*). Returns the first match or raises :exc:`ValueError` if not found.
python, official-docs, cpython, P0
Local_Trusted_Corpus
5ea4e617-b3c4-4c7c-94a0-4a13dce07fa8
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,224
supabase-export-v2
2bb09eb8d3ecff01
:meth:`~object.__getitem__` method of the :class:`dict` class when the requested key is not found; whatever it returns or raises is then returned or raised by :meth:`~object.__getitem__`. Note that :meth:`__missing__` is *not* called for any operations besides :meth:`~object.__getitem__`. This means that :meth:`~dict....
trusted_official_docs
CPython Docs
:meth:`~object.__getitem__` method of the :class:`dict` class when the requested key is not found; whatever it returns or raises is then returned or raised by :meth:`~object.__getitem__`. Note that :meth:`__missing__` is *not* called for any operations besides :meth:`~object.__getitem__`. This means that :meth:`~dict....
:meth:`~object.__getitem__` method of the :class:`dict` class when the requested key is not found; whatever it returns or raises is then returned or raised by :meth:`~object.__getitem__`. Note that :meth:`__missing__` is *not* called for any operations besides :meth:`~object.__getitem__`. This means that :meth:`~dict....
python, official-docs, cpython, P0
Local_Trusted_Corpus
5f48b10e-ceac-4683-b9ee-e36c754d5cd4
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,339
supabase-export-v2
7cd3e468be5e4365
.. versionchanged:: 3.6 With the acceptance of :pep:`468`, order is retained for keyword arguments passed to the :class:`OrderedDict` constructor and its :meth:`~dict.update` method. .. versionchanged:: 3.9 Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`.
trusted_official_docs
CPython Docs
.. versionchanged:: 3.6 With the acceptance of :pep:`468`, order is retained for keyword arguments passed to the :class:`OrderedDict` constructor and its :meth:`~dict.update` method. .. versionchanged:: 3.9 Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`.
.. versionchanged:: 3.6 With the acceptance of :pep:`468`, order is retained for keyword arguments passed to the :class:`OrderedDict` constructor and its :meth:`~dict.update` method. .. versionchanged:: 3.9 Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`.
python, official-docs, cpython, P0
Local_Trusted_Corpus
600454e5-f32e-4d8d-83ad-fa6e8bf6ecf1
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,301
supabase-export-v2
1aae1d6f153a8662
Docstrings can be customized by making direct assignments to the ``__doc__`` fields: >>> Book = namedtuple('Book', ['id', 'title', 'authors']) >>> Book.__doc__ += ': Hardcover book in active collection' >>> Book.id.__doc__ = '13-digit ISBN' >>> Book.title.__doc__ = 'Title of first printing' >>> Book.authors.__doc__...
trusted_official_docs
CPython Docs
Docstrings can be customized by making direct assignments to the ``__doc__`` fields: >>> Book = namedtuple('Book', ['id', 'title', 'authors']) >>> Book.__doc__ += ': Hardcover book in active collection' >>> Book.id.__doc__ = '13-digit ISBN' >>> Book.title.__doc__ = 'Title of first printing' >>> Book.authors.__doc__...
Docstrings can be customized by making direct assignments to the ``__doc__`` fields: >>> Book = namedtuple('Book', ['id', 'title', 'authors']) >>> Book.__doc__ += ': Hardcover book in active collection' >>> Book.id.__doc__ = '13-digit ISBN' >>> Book.title.__doc__ = 'Title of first printing' >>> Book.authors.__doc__...
python, official-docs, cpython, P0
Local_Trusted_Corpus
60f06200-951b-43e5-ae12-31794072b126
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,376
supabase-export-v2
6b706feabb670996
A real :class:`list` object used to store the contents of the :class:`UserList` class. **Subclassing requirements:** Subclasses of :class:`UserList` are expected to offer a constructor which can be called with either no arguments or one argument. List operations which return a new sequence attempt to create an instance...
trusted_official_docs
CPython Docs
A real :class:`list` object used to store the contents of the :class:`UserList` class. **Subclassing requirements:** Subclasses of :class:`UserList` are expected to offer a constructor which can be called with either no arguments or one argument. List operations which return a new sequence attempt to create an instance...
A real :class:`list` object used to store the contents of the :class:`UserList` class. **Subclassing requirements:** Subclasses of :class:`UserList` are expected to offer a constructor which can be called with either no arguments or one argument. List operations which return a new sequence attempt to create an instance...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6141f323-1e1f-4cdc-b595-26ed79b0d134
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,096
supabase-export-v2
0f00d071c3d7e033
= re.findall(r'\w+', open('hamlet.txt').read().lower()) >>> Counter(words).most_common(10) [('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631), ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)] .. class:: Counter(**kwargs) Counter(iterable, /, **kwargs) Counter(mapping, /, **kwargs)
trusted_official_docs
CPython Docs
= re.findall(r'\w+', open('hamlet.txt').read().lower()) >>> Counter(words).most_common(10) [('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631), ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)] .. class:: Counter(**kwargs) Counter(iterable, /, **kwargs) Counter(mapping, /, **kwargs)
= re.findall(r'\w+', open('hamlet.txt').read().lower()) >>> Counter(words).most_common(10) [('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631), ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)] .. class:: Counter(**kwargs) Counter(iterable, /, **kwargs) Counter(mapping, /, **kwargs)
python, official-docs, cpython, P0
Local_Trusted_Corpus
61442140-0291-41c3-99e7-ddd321a09cda
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,240
supabase-export-v2
830a2819531f37c4
Setting the :attr:`~defaultdict.default_factory` to :class:`set` makes the :class:`defaultdict` useful for building a dictionary of sets: >>> s = [('red', 1), ('blue', 2), ('red', 3), ('blue', 4), ('red', 1), ('blue', 4)] >>> d = defaultdict(set) >>> for k, v in s: ... d[k].add(v) ... >>> sorted(d.items()) [('blue...
trusted_official_docs
CPython Docs
Setting the :attr:`~defaultdict.default_factory` to :class:`set` makes the :class:`defaultdict` useful for building a dictionary of sets: >>> s = [('red', 1), ('blue', 2), ('red', 3), ('blue', 4), ('red', 1), ('blue', 4)] >>> d = defaultdict(set) >>> for k, v in s: ... d[k].add(v) ... >>> sorted(d.items()) [('blue...
Setting the :attr:`~defaultdict.default_factory` to :class:`set` makes the :class:`defaultdict` useful for building a dictionary of sets: >>> s = [('red', 1), ('blue', 2), ('red', 3), ('blue', 4), ('red', 1), ('blue', 4)] >>> d = defaultdict(set) >>> for k, v in s: ... d[k].add(v) ... >>> sorted(d.items()) [('blue...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6210250e-1e06-4ab9-a961-b19fa65e5f9d
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,102
supabase-export-v2
213c51495cd071b7
>>> c = Counter(['eggs', 'ham']) >>> c['bacon'] # count of a missing element is zero 0 Setting a count to zero does not remove an element from a counter. Use ``del`` to remove it entirely:
trusted_official_docs
CPython Docs
>>> c = Counter(['eggs', 'ham']) >>> c['bacon'] # count of a missing element is zero 0 Setting a count to zero does not remove an element from a counter. Use ``del`` to remove it entirely:
>>> c = Counter(['eggs', 'ham']) >>> c['bacon'] # count of a missing element is zero 0 Setting a count to zero does not remove an element from a counter. Use ``del`` to remove it entirely:
python, official-docs, cpython, P0
Local_Trusted_Corpus
63f97a24-6a1b-441c-88c0-f858e677b3ff
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,103
supabase-export-v2
d66707d72024836b
Setting a count to zero does not remove an element from a counter. Use ``del`` to remove it entirely: >>> c['sausage'] = 0 # counter entry with a zero count >>> del c['sausage'] # del actually removes the entry
trusted_official_docs
CPython Docs
Setting a count to zero does not remove an element from a counter. Use ``del`` to remove it entirely: >>> c['sausage'] = 0 # counter entry with a zero count >>> del c['sausage'] # del actually removes the entry
Setting a count to zero does not remove an element from a counter. Use ``del`` to remove it entirely: >>> c['sausage'] = 0 # counter entry with a zero count >>> del c['sausage'] # del actually removes the entry
python, official-docs, cpython, P0
Local_Trusted_Corpus
6449ef9d-3ebe-4794-aabe-ce2af2b78875
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,247
supabase-export-v2
c45b264e7f0bf5d7
and underscores but do not start with a digit or underscore and cannot be a :mod:`keyword` such as *class*, *for*, *return*, *global*, *pass*, or *raise*. If *rename* is true, invalid fieldnames are automatically replaced with positional names. For example, ``['abc', 'def', 'ghi', 'abc']`` is converted to ``['abc', '...
trusted_official_docs
CPython Docs
and underscores but do not start with a digit or underscore and cannot be a :mod:`keyword` such as *class*, *for*, *return*, *global*, *pass*, or *raise*. If *rename* is true, invalid fieldnames are automatically replaced with positional names. For example, ``['abc', 'def', 'ghi', 'abc']`` is converted to ``['abc', '...
and underscores but do not start with a digit or underscore and cannot be a :mod:`keyword` such as *class*, *for*, *return*, *global*, *pass*, or *raise*. If *rename* is true, invalid fieldnames are automatically replaced with positional names. For example, ``['abc', 'def', 'ghi', 'abc']`` is converted to ``['abc', '...
python, official-docs, cpython, P0
Local_Trusted_Corpus
648b9fa7-6c30-4547-85a8-beeddad7db68
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,189
supabase-export-v2
ea9bd4337ffe0ffc
Rotate the deque *n* steps to the right. If *n* is negative, rotate to the left. When the deque is not empty, rotating one step to the right is equivalent to ``d.appendleft(d.pop())``, and rotating one step to the left is equivalent to ``d.append(d.popleft())``.
trusted_official_docs
CPython Docs
Rotate the deque *n* steps to the right. If *n* is negative, rotate to the left. When the deque is not empty, rotating one step to the right is equivalent to ``d.appendleft(d.pop())``, and rotating one step to the left is equivalent to ``d.append(d.popleft())``.
Rotate the deque *n* steps to the right. If *n* is negative, rotate to the left. When the deque is not empty, rotating one step to the right is equivalent to ``d.appendleft(d.pop())``, and rotating one step to the left is equivalent to ``d.append(d.popleft())``.
python, official-docs, cpython, P0
Local_Trusted_Corpus
66074733-8123-45f2-90f1-bc3bf2a74392
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,348
supabase-export-v2
59e37443d4b92b88
class TimeBoundedLRU: "LRU Cache that invalidates and refreshes old entries." def __init__(self, func, maxsize=128, maxage=30): self.cache = OrderedDict() # { args : (timestamp, result)} self.func = func self.maxsize = maxsize self.maxage = maxage
trusted_official_docs
CPython Docs
class TimeBoundedLRU: "LRU Cache that invalidates and refreshes old entries." def __init__(self, func, maxsize=128, maxage=30): self.cache = OrderedDict() # { args : (timestamp, result)} self.func = func self.maxsize = maxsize self.maxage = maxage
class TimeBoundedLRU: "LRU Cache that invalidates and refreshes old entries." def __init__(self, func, maxsize=128, maxage=30): self.cache = OrderedDict() # { args : (timestamp, result)} self.func = func self.maxsize = maxsize self.maxage = maxage
python, official-docs, cpython, P0
Local_Trusted_Corpus
6a8a15ca-41c3-4e81-ab43-8c7b1b70aa1d
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,354
supabase-export-v2
4bb774865bbb5dde
""" def __init__(self, func, maxsize=128, maxrequests=4096, cache_after=1): self.requests = OrderedDict() # { uncached_key : request_count } self.cache = OrderedDict() # { cached_key : function_result } self.func = func self.maxrequests = maxrequests # max number of uncached requests self.maxsize = maxsize # max n...
trusted_official_docs
CPython Docs
""" def __init__(self, func, maxsize=128, maxrequests=4096, cache_after=1): self.requests = OrderedDict() # { uncached_key : request_count } self.cache = OrderedDict() # { cached_key : function_result } self.func = func self.maxrequests = maxrequests # max number of uncached requests self.maxsize = maxsize # max n...
""" def __init__(self, func, maxsize=128, maxrequests=4096, cache_after=1): self.requests = OrderedDict() # { uncached_key : request_count } self.cache = OrderedDict() # { cached_key : function_result } self.func = func self.maxrequests = maxrequests # max number of uncached requests self.maxsize = maxsize # max n...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6aafaf56-bd09-459a-b8a9-8a03f6cd90a9
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,295
supabase-export-v2
c8042c6afe031d84
.. doctest:: >>> class Point(namedtuple('Point', ['x', 'y'])): ... __slots__ = () ... @property ... def hypot(self): ... return (self.x ** 2 + self.y ** 2) ** 0.5 ... def __str__(self): ... return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot)
trusted_official_docs
CPython Docs
.. doctest:: >>> class Point(namedtuple('Point', ['x', 'y'])): ... __slots__ = () ... @property ... def hypot(self): ... return (self.x ** 2 + self.y ** 2) ** 0.5 ... def __str__(self): ... return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot)
.. doctest:: >>> class Point(namedtuple('Point', ['x', 'y'])): ... __slots__ = () ... @property ... def hypot(self): ... return (self.x ** 2 + self.y ** 2) ** 0.5 ... def __str__(self): ... return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot)
python, official-docs, cpython, P0
Local_Trusted_Corpus
6dec01ac-a2da-4ff5-86cf-d62ae721e4ff
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,373
supabase-export-v2
a19333fd0528b4cd
a copy of *list*, defaulting to the empty list ``[]``. *list* can be any iterable, for example a real Python list or a :class:`UserList` object. In addition to supporting the methods and operations of mutable sequences, :class:`UserList` instances provide the following attribute:
trusted_official_docs
CPython Docs
a copy of *list*, defaulting to the empty list ``[]``. *list* can be any iterable, for example a real Python list or a :class:`UserList` object. In addition to supporting the methods and operations of mutable sequences, :class:`UserList` instances provide the following attribute:
a copy of *list*, defaulting to the empty list ``[]``. *list* can be any iterable, for example a real Python list or a :class:`UserList` object. In addition to supporting the methods and operations of mutable sequences, :class:`UserList` instances provide the following attribute:
python, official-docs, cpython, P0
Local_Trusted_Corpus
6e4cf7ff-1a94-4678-8193-763278582f65
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,250
supabase-export-v2
06044fb3fad6a837
If *module* is defined, the :attr:`~type.__module__` attribute of the named tuple is set to that value. Named tuple instances do not have per-instance dictionaries, so they are lightweight and require no more memory than regular tuples.
trusted_official_docs
CPython Docs
If *module* is defined, the :attr:`~type.__module__` attribute of the named tuple is set to that value. Named tuple instances do not have per-instance dictionaries, so they are lightweight and require no more memory than regular tuples.
If *module* is defined, the :attr:`~type.__module__` attribute of the named tuple is set to that value. Named tuple instances do not have per-instance dictionaries, so they are lightweight and require no more memory than regular tuples.
python, official-docs, cpython, P0
Local_Trusted_Corpus
73e4a651-52c0-4671-82ba-bb1dab91fbc6
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,054
supabase-export-v2
986867ea6e620e0e
mappings are stored in a list. That list is public and can be accessed or updated using the *maps* attribute. There is no other state. Lookups search the underlying mappings successively until a key is found. In contrast, writes, updates, and deletions only operate on the first mapping.
trusted_official_docs
CPython Docs
mappings are stored in a list. That list is public and can be accessed or updated using the *maps* attribute. There is no other state. Lookups search the underlying mappings successively until a key is found. In contrast, writes, updates, and deletions only operate on the first mapping.
mappings are stored in a list. That list is public and can be accessed or updated using the *maps* attribute. There is no other state. Lookups search the underlying mappings successively until a key is found. In contrast, writes, updates, and deletions only operate on the first mapping.
python, official-docs, cpython, P0
Local_Trusted_Corpus
74466638-1fb5-4202-9be8-44d2cd75f9f7
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,239
supabase-export-v2
29b77b65ed4f5234
def constant_factory(value): ... return lambda: value ... >>> d = defaultdict(constant_factory('<missing>')) >>> d.update(name='John', action='ran') >>> '%(name)s %(action)s to %(object)s' % d 'John ran to <missing>' Setting the :attr:`~defaultdict.default_factory` to :class:`set` makes the :class:`defaultdict` useful ...
trusted_official_docs
CPython Docs
def constant_factory(value): ... return lambda: value ... >>> d = defaultdict(constant_factory('<missing>')) >>> d.update(name='John', action='ran') >>> '%(name)s %(action)s to %(object)s' % d 'John ran to <missing>' Setting the :attr:`~defaultdict.default_factory` to :class:`set` makes the :class:`defaultdict` useful ...
def constant_factory(value): ... return lambda: value ... >>> d = defaultdict(constant_factory('<missing>')) >>> d.update(name='John', action='ran') >>> '%(name)s %(action)s to %(object)s' % d 'John ran to <missing>' Setting the :attr:`~defaultdict.default_factory` to :class:`set` makes the :class:`defaultdict` useful ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
74d2b407-2ed3-4755-9c96-095eb18f8261
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,296
supabase-export-v2
c9c71436b4843764
hypot(self): ... return (self.x ** 2 + self.y ** 2) ** 0.5 ... def __str__(self): ... return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot) >>> for p in Point(3, 4), Point(14, 5/7): ... print(p) Point: x= 3.000 y= 4.000 hypot= 5.000 Point: x=14.000 y= 0.714 hypot=14.018
trusted_official_docs
CPython Docs
hypot(self): ... return (self.x ** 2 + self.y ** 2) ** 0.5 ... def __str__(self): ... return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot) >>> for p in Point(3, 4), Point(14, 5/7): ... print(p) Point: x= 3.000 y= 4.000 hypot= 5.000 Point: x=14.000 y= 0.714 hypot=14.018
hypot(self): ... return (self.x ** 2 + self.y ** 2) ** 0.5 ... def __str__(self): ... return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot) >>> for p in Point(3, 4), Point(14, 5/7): ... print(p) Point: x= 3.000 y= 4.000 hypot= 5.000 Point: x=14.000 y= 0.714 hypot=14.018
python, official-docs, cpython, P0
Local_Trusted_Corpus
750693f3-c34a-42a7-8645-119ca58fe2f3
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,097
supabase-export-v2
68ed0e717f897491
.. class:: Counter(**kwargs) Counter(iterable, /, **kwargs) Counter(mapping, /, **kwargs) A :class:`Counter` is a :class:`dict` subclass for counting :term:`hashable` objects. It is a collection where elements are stored as dictionary keys and their counts are stored as dictionary values. Counts are allowed to be any...
trusted_official_docs
CPython Docs
.. class:: Counter(**kwargs) Counter(iterable, /, **kwargs) Counter(mapping, /, **kwargs) A :class:`Counter` is a :class:`dict` subclass for counting :term:`hashable` objects. It is a collection where elements are stored as dictionary keys and their counts are stored as dictionary values. Counts are allowed to be any...
.. class:: Counter(**kwargs) Counter(iterable, /, **kwargs) Counter(mapping, /, **kwargs) A :class:`Counter` is a :class:`dict` subclass for counting :term:`hashable` objects. It is a collection where elements are stored as dictionary keys and their counts are stored as dictionary values. Counts are allowed to be any...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7571a89c-0924-4e91-bdcc-e87cb3dd9d1b
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,297
supabase-export-v2
35d4fb71b8ca7627
>>> for p in Point(3, 4), Point(14, 5/7): ... print(p) Point: x= 3.000 y= 4.000 hypot= 5.000 Point: x=14.000 y= 0.714 hypot=14.018 The subclass shown above sets ``__slots__`` to an empty tuple. This helps keep memory requirements low by preventing the creation of instance dictionaries.
trusted_official_docs
CPython Docs
>>> for p in Point(3, 4), Point(14, 5/7): ... print(p) Point: x= 3.000 y= 4.000 hypot= 5.000 Point: x=14.000 y= 0.714 hypot=14.018 The subclass shown above sets ``__slots__`` to an empty tuple. This helps keep memory requirements low by preventing the creation of instance dictionaries.
>>> for p in Point(3, 4), Point(14, 5/7): ... print(p) Point: x= 3.000 y= 4.000 hypot= 5.000 Point: x=14.000 y= 0.714 hypot=14.018 The subclass shown above sets ``__slots__`` to an empty tuple. This helps keep memory requirements low by preventing the creation of instance dictionaries.
python, official-docs, cpython, P0
Local_Trusted_Corpus
7623b9dd-ecb1-49b3-97cb-279e520b71f3
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,149
supabase-export-v2
505c571783e12a49
* For mathematical operations on multisets and their use cases, see *Knuth, Donald. The Art of Computer Programming Volume II, Section 4.6.3, Exercise 19*. * To enumerate all distinct multisets of a given size over a given set of elements, see :func:`itertools.combinations_with_replacement`::
trusted_official_docs
CPython Docs
* For mathematical operations on multisets and their use cases, see *Knuth, Donald. The Art of Computer Programming Volume II, Section 4.6.3, Exercise 19*. * To enumerate all distinct multisets of a given size over a given set of elements, see :func:`itertools.combinations_with_replacement`::
* For mathematical operations on multisets and their use cases, see *Knuth, Donald. The Art of Computer Programming Volume II, Section 4.6.3, Exercise 19*. * To enumerate all distinct multisets of a given size over a given set of elements, see :func:`itertools.combinations_with_replacement`::
python, official-docs, cpython, P0
Local_Trusted_Corpus
78ad9768-5648-46eb-953a-28677c83a1ec
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,370
supabase-export-v2
9329edfae9e322ab
list-like classes which can inherit from them and override existing methods or add new ones. In this way, one can add new behaviors to lists. The need for this class has been partially supplanted by the ability to subclass directly from :class:`list`; however, this class can be easier to work with because the underlyin...
trusted_official_docs
CPython Docs
list-like classes which can inherit from them and override existing methods or add new ones. In this way, one can add new behaviors to lists. The need for this class has been partially supplanted by the ability to subclass directly from :class:`list`; however, this class can be easier to work with because the underlyin...
list-like classes which can inherit from them and override existing methods or add new ones. In this way, one can add new behaviors to lists. The need for this class has been partially supplanted by the ability to subclass directly from :class:`list`; however, this class can be easier to work with because the underlyin...
python, official-docs, cpython, P0
Local_Trusted_Corpus
78ba4987-f481-4bfe-aca6-763a2d3f03f7
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,248
supabase-export-v2
3fc86004c4e7affa
with positional names. For example, ``['abc', 'def', 'ghi', 'abc']`` is converted to ``['abc', '_1', 'ghi', '_3']``, eliminating the keyword ``def`` and the duplicate fieldname ``abc``. *defaults* can be ``None`` or an :term:`iterable` of default values. Since fields with a default value must come after any fields with...
trusted_official_docs
CPython Docs
with positional names. For example, ``['abc', 'def', 'ghi', 'abc']`` is converted to ``['abc', '_1', 'ghi', '_3']``, eliminating the keyword ``def`` and the duplicate fieldname ``abc``. *defaults* can be ``None`` or an :term:`iterable` of default values. Since fields with a default value must come after any fields with...
with positional names. For example, ``['abc', 'def', 'ghi', 'abc']`` is converted to ``['abc', '_1', 'ghi', '_3']``, eliminating the keyword ``def`` and the duplicate fieldname ``abc``. *defaults* can be ``None`` or an :term:`iterable` of default values. Since fields with a default value must come after any fields with...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7a03d8b6-bc68-40ce-9f68-6cf017c8790b
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,172
supabase-export-v2
ceb9626f62323a5e
.. method:: extendleft(iterable, /) Extend the left side of the deque by appending elements from *iterable*. Note, the series of left appends results in reversing the order of elements in the iterable argument.
trusted_official_docs
CPython Docs
.. method:: extendleft(iterable, /) Extend the left side of the deque by appending elements from *iterable*. Note, the series of left appends results in reversing the order of elements in the iterable argument.
.. method:: extendleft(iterable, /) Extend the left side of the deque by appending elements from *iterable*. Note, the series of left appends results in reversing the order of elements in the iterable argument.
python, official-docs, cpython, P0
Local_Trusted_Corpus
7afae455-6b71-47be-ae64-c8c9e5dd6af5
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,109
supabase-export-v2
34d7ba451a52d55a
many times as its count. Elements are returned in the order first encountered. If an element's count is less than one, :meth:`elements` will ignore it. >>> c = Counter(a=4, b=2, c=0, d=-2) >>> sorted(c.elements()) ['a', 'a', 'a', 'a', 'b', 'b']
trusted_official_docs
CPython Docs
many times as its count. Elements are returned in the order first encountered. If an element's count is less than one, :meth:`elements` will ignore it. >>> c = Counter(a=4, b=2, c=0, d=-2) >>> sorted(c.elements()) ['a', 'a', 'a', 'a', 'b', 'b']
many times as its count. Elements are returned in the order first encountered. If an element's count is less than one, :meth:`elements` will ignore it. >>> c = Counter(a=4, b=2, c=0, d=-2) >>> sorted(c.elements()) ['a', 'a', 'a', 'a', 'b', 'b']
python, official-docs, cpython, P0
Local_Trusted_Corpus
7b9f3799-786d-44f3-ad4a-3ff16edd6a81
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,061
supabase-export-v2
079da1b705189529
map or new empty dict. This method is used for creating subcontexts that can be updated without altering values in any of the parent mappings. .. versionchanged:: 3.4 The optional ``m`` parameter was added.
trusted_official_docs
CPython Docs
map or new empty dict. This method is used for creating subcontexts that can be updated without altering values in any of the parent mappings. .. versionchanged:: 3.4 The optional ``m`` parameter was added.
map or new empty dict. This method is used for creating subcontexts that can be updated without altering values in any of the parent mappings. .. versionchanged:: 3.4 The optional ``m`` parameter was added.
python, official-docs, cpython, P0
Local_Trusted_Corpus
7e662bb1-4444-497b-9f60-ff957f7bde54
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,302
supabase-export-v2
0950cf14f57cb51b
in active collection' >>> Book.id.__doc__ = '13-digit ISBN' >>> Book.title.__doc__ = 'Title of first printing' >>> Book.authors.__doc__ = 'List of authors sorted by last name' .. versionchanged:: 3.5 Property docstrings became writeable.
trusted_official_docs
CPython Docs
in active collection' >>> Book.id.__doc__ = '13-digit ISBN' >>> Book.title.__doc__ = 'Title of first printing' >>> Book.authors.__doc__ = 'List of authors sorted by last name' .. versionchanged:: 3.5 Property docstrings became writeable.
in active collection' >>> Book.id.__doc__ = '13-digit ISBN' >>> Book.title.__doc__ = 'Title of first printing' >>> Book.authors.__doc__ = 'List of authors sorted by last name' .. versionchanged:: 3.5 Property docstrings became writeable.
python, official-docs, cpython, P0
Local_Trusted_Corpus
7ea89ded-78ca-4f6f-a917-6acc74ab63ce
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,315
supabase-export-v2
e1da7910954746b9
* The equality operation for :class:`OrderedDict` checks for matching order. A regular :class:`dict` can emulate the order sensitive equality test with ``p == q and all(k1 == k2 for k1, k2 in zip(p, q))``.
trusted_official_docs
CPython Docs
* The equality operation for :class:`OrderedDict` checks for matching order. A regular :class:`dict` can emulate the order sensitive equality test with ``p == q and all(k1 == k2 for k1, k2 in zip(p, q))``.
* The equality operation for :class:`OrderedDict` checks for matching order. A regular :class:`dict` can emulate the order sensitive equality test with ``p == q and all(k1 == k2 for k1, k2 in zip(p, q))``.
python, official-docs, cpython, P0
Local_Trusted_Corpus
7eb779bf-6367-4f3b-99b6-8e7bdc7c50dc
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,053
supabase-export-v2
739f3d3a89ae8702
single, updateable view. If no *maps* are specified, a single empty dictionary is provided so that a new chain always has at least one mapping. The underlying mappings are stored in a list. That list is public and can be accessed or updated using the *maps* attribute. There is no other state.
trusted_official_docs
CPython Docs
single, updateable view. If no *maps* are specified, a single empty dictionary is provided so that a new chain always has at least one mapping. The underlying mappings are stored in a list. That list is public and can be accessed or updated using the *maps* attribute. There is no other state.
single, updateable view. If no *maps* are specified, a single empty dictionary is provided so that a new chain always has at least one mapping. The underlying mappings are stored in a list. That list is public and can be accessed or updated using the *maps* attribute. There is no other state.
python, official-docs, cpython, P0
Local_Trusted_Corpus
7f5f60ec-70c0-4f4c-be46-966cd709e85b
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,361
supabase-export-v2
42dc4ac649256225
.. class:: UserDict(**kwargs) UserDict(mapping, /, **kwargs) UserDict(iterable, /, **kwargs) Class that simulates a dictionary. The instance's contents are kept in a regular dictionary, which is accessible via the :attr:`data` attribute of :class:`!UserDict` instances. If arguments are provided, they are used to ini...
trusted_official_docs
CPython Docs
.. class:: UserDict(**kwargs) UserDict(mapping, /, **kwargs) UserDict(iterable, /, **kwargs) Class that simulates a dictionary. The instance's contents are kept in a regular dictionary, which is accessible via the :attr:`data` attribute of :class:`!UserDict` instances. If arguments are provided, they are used to ini...
.. class:: UserDict(**kwargs) UserDict(mapping, /, **kwargs) UserDict(iterable, /, **kwargs) Class that simulates a dictionary. The instance's contents are kept in a regular dictionary, which is accessible via the :attr:`data` attribute of :class:`!UserDict` instances. If arguments are provided, they are used to ini...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7fbc319f-a6cd-4839-aa07-0fc7fcab674b
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,246
supabase-export-v2
fdf173b130c681ef
as ``['x', 'y']``. Alternatively, *field_names* can be a single string with each fieldname separated by whitespace and/or commas, for example ``'x y'`` or ``'x, y'``. Any valid Python identifier may be used for a fieldname except for names starting with an underscore. Valid identifiers consist of letters, digits, and...
trusted_official_docs
CPython Docs
as ``['x', 'y']``. Alternatively, *field_names* can be a single string with each fieldname separated by whitespace and/or commas, for example ``'x y'`` or ``'x, y'``. Any valid Python identifier may be used for a fieldname except for names starting with an underscore. Valid identifiers consist of letters, digits, and...
as ``['x', 'y']``. Alternatively, *field_names* can be a single string with each fieldname separated by whitespace and/or commas, for example ``'x y'`` or ``'x, y'``. Any valid Python identifier may be used for a fieldname except for names starting with an underscore. Valid identifiers consist of letters, digits, and...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8395efb4-533c-4161-8a7b-7e5fbbd5b300
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,259
supabase-export-v2
c574a91e69586fa6
y (11, 22) >>> p.x + p.y # fields also accessible by name 33 >>> p # readable __repr__ with a name=value style Point(x=11, y=22) Named tuples are especially useful for assigning field names to result tuples returned by the :mod:`csv` or :mod:`sqlite3` modules::
trusted_official_docs
CPython Docs
y (11, 22) >>> p.x + p.y # fields also accessible by name 33 >>> p # readable __repr__ with a name=value style Point(x=11, y=22) Named tuples are especially useful for assigning field names to result tuples returned by the :mod:`csv` or :mod:`sqlite3` modules::
y (11, 22) >>> p.x + p.y # fields also accessible by name 33 >>> p # readable __repr__ with a name=value style Point(x=11, y=22) Named tuples are especially useful for assigning field names to result tuples returned by the :mod:`csv` or :mod:`sqlite3` modules::
python, official-docs, cpython, P0
Local_Trusted_Corpus
84ff6a0a-9165-41cb-99c9-4939b3d58a6b
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,129
supabase-export-v2
c3b278eaebf85123
Common patterns for working with :class:`Counter` objects:: c.total() # total of all counts c.clear() # reset all counts list(c) # list unique elements set(c) # convert to a set dict(c) # convert to a regular dictionary c.items() # access the (elem, cnt) pairs Counter(dict(list_of_pairs)) # convert from a list of...
trusted_official_docs
CPython Docs
Common patterns for working with :class:`Counter` objects:: c.total() # total of all counts c.clear() # reset all counts list(c) # list unique elements set(c) # convert to a set dict(c) # convert to a regular dictionary c.items() # access the (elem, cnt) pairs Counter(dict(list_of_pairs)) # convert from a list of...
Common patterns for working with :class:`Counter` objects:: c.total() # total of all counts c.clear() # reset all counts list(c) # list unique elements set(c) # convert to a set dict(c) # convert to a regular dictionary c.items() # access the (elem, cnt) pairs Counter(dict(list_of_pairs)) # convert from a list of...
python, official-docs, cpython, P0
Local_Trusted_Corpus
89807cc7-8fa8-44c9-b354-cf30e25c804a
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,228
supabase-export-v2
08333d046605211e
This attribute is used by the :meth:`~defaultdict.__missing__` method; it is initialized from the first argument to the constructor, if present, or to ``None``, if absent. .. versionchanged:: 3.9 Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`.
trusted_official_docs
CPython Docs
This attribute is used by the :meth:`~defaultdict.__missing__` method; it is initialized from the first argument to the constructor, if present, or to ``None``, if absent. .. versionchanged:: 3.9 Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`.
This attribute is used by the :meth:`~defaultdict.__missing__` method; it is initialized from the first argument to the constructor, if present, or to ``None``, if absent. .. versionchanged:: 3.9 Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`.
python, official-docs, cpython, P0
Local_Trusted_Corpus
8a00c439-b843-4c09-b979-389b592c5cea
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,106
supabase-export-v2
ff9d1ecacb3f7a3c
Results are ordered according to when an element is first encountered in the left operand and then by the order encountered in the right operand. Counter objects support additional methods beyond those available for all dictionaries:
trusted_official_docs
CPython Docs
Results are ordered according to when an element is first encountered in the left operand and then by the order encountered in the right operand. Counter objects support additional methods beyond those available for all dictionaries:
Results are ordered according to when an element is first encountered in the left operand and then by the order encountered in the right operand. Counter objects support additional methods beyond those available for all dictionaries:
python, official-docs, cpython, P0
Local_Trusted_Corpus
8b47cea5-8f3a-4e59-9569-985274cf07c0
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,067
supabase-export-v2
561532dffe09b51f
>>> baseline = {'music': 'bach', 'art': 'rembrandt'} >>> adjustments = {'art': 'van gogh', 'opera': 'carmen'} >>> list(ChainMap(adjustments, baseline)) ['music', 'art', 'opera'] This gives the same ordering as a series of :meth:`dict.update` calls starting with the last mapping::
trusted_official_docs
CPython Docs
>>> baseline = {'music': 'bach', 'art': 'rembrandt'} >>> adjustments = {'art': 'van gogh', 'opera': 'carmen'} >>> list(ChainMap(adjustments, baseline)) ['music', 'art', 'opera'] This gives the same ordering as a series of :meth:`dict.update` calls starting with the last mapping::
>>> baseline = {'music': 'bach', 'art': 'rembrandt'} >>> adjustments = {'art': 'van gogh', 'opera': 'carmen'} >>> list(ChainMap(adjustments, baseline)) ['music', 'art', 'opera'] This gives the same ordering as a series of :meth:`dict.update` calls starting with the last mapping::
python, official-docs, cpython, P0
Local_Trusted_Corpus
8b79e8ec-7983-4340-ae74-8b74a04ff657
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,231
supabase-export-v2
83f3de0123528b8c
Using :class:`list` as the :attr:`~defaultdict.default_factory`, it is easy to group a sequence of key-value pairs into a dictionary of lists: >>> s = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)] >>> d = defaultdict(list) >>> for k, v in s: ... d[k].append(v) ... >>> sorted(d.items()) [('bl...
trusted_official_docs
CPython Docs
Using :class:`list` as the :attr:`~defaultdict.default_factory`, it is easy to group a sequence of key-value pairs into a dictionary of lists: >>> s = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)] >>> d = defaultdict(list) >>> for k, v in s: ... d[k].append(v) ... >>> sorted(d.items()) [('bl...
Using :class:`list` as the :attr:`~defaultdict.default_factory`, it is easy to group a sequence of key-value pairs into a dictionary of lists: >>> s = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)] >>> d = defaultdict(list) >>> for k, v in s: ... d[k].append(v) ... >>> sorted(d.items()) [('bl...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8d4e7aa1-168a-470f-91e3-7dd06160aee5
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,050
supabase-export-v2
75597d9a34b89387
mappings so they can be treated as a single unit. It is often much faster than creating a new dictionary and running multiple :meth:`~dict.update` calls. The class can be used to simulate nested scopes and is useful in templating.
trusted_official_docs
CPython Docs
mappings so they can be treated as a single unit. It is often much faster than creating a new dictionary and running multiple :meth:`~dict.update` calls. The class can be used to simulate nested scopes and is useful in templating.
mappings so they can be treated as a single unit. It is often much faster than creating a new dictionary and running multiple :meth:`~dict.update` calls. The class can be used to simulate nested scopes and is useful in templating.
python, official-docs, cpython, P0
Local_Trusted_Corpus
8dd7a2d0-917e-4ae7-a3f9-6ba0f591fe13
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,088
supabase-export-v2
7ec67f4d79077cf3
full chain. However, if deep writes and deletions are desired, it is easy to make a subclass that updates keys found deeper in the chain:: class DeepChainMap(ChainMap): 'Variant of ChainMap that allows direct updates to inner scopes'
trusted_official_docs
CPython Docs
full chain. However, if deep writes and deletions are desired, it is easy to make a subclass that updates keys found deeper in the chain:: class DeepChainMap(ChainMap): 'Variant of ChainMap that allows direct updates to inner scopes'
full chain. However, if deep writes and deletions are desired, it is easy to make a subclass that updates keys found deeper in the chain:: class DeepChainMap(ChainMap): 'Variant of ChainMap that allows direct updates to inner scopes'
python, official-docs, cpython, P0
Local_Trusted_Corpus
8dfaff2d-60a8-4ce3-92d0-1f0a48c85437
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,210
supabase-export-v2
f43ffcb1da9bc553
zero. If that iterator is exhausted, it can be removed with :meth:`~deque.popleft`; otherwise, it can be cycled back to the end with the :meth:`~deque.rotate` method:: def roundrobin(*iterables): "roundrobin('ABC', 'D', 'EF') --> A D E B F C" iterators = deque(map(iter, iterables)) while iterators: try: while True...
trusted_official_docs
CPython Docs
zero. If that iterator is exhausted, it can be removed with :meth:`~deque.popleft`; otherwise, it can be cycled back to the end with the :meth:`~deque.rotate` method:: def roundrobin(*iterables): "roundrobin('ABC', 'D', 'EF') --> A D E B F C" iterators = deque(map(iter, iterables)) while iterators: try: while True...
zero. If that iterator is exhausted, it can be removed with :meth:`~deque.popleft`; otherwise, it can be cycled back to the end with the :meth:`~deque.rotate` method:: def roundrobin(*iterables): "roundrobin('ABC', 'D', 'EF') --> A D E B F C" iterators = deque(map(iter, iterables)) while iterators: try: while True...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8ee29d73-15cb-4510-895f-2a793b5a4697
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,056
supabase-export-v2
2c12ef832be5d4ad
A :class:`ChainMap` incorporates the underlying mappings by reference. So, if one of the underlying mappings gets updated, those changes will be reflected in :class:`ChainMap`. All of the usual dictionary methods are supported. In addition, there is a *maps* attribute, a method for creating new subcontexts, and a prop...
trusted_official_docs
CPython Docs
A :class:`ChainMap` incorporates the underlying mappings by reference. So, if one of the underlying mappings gets updated, those changes will be reflected in :class:`ChainMap`. All of the usual dictionary methods are supported. In addition, there is a *maps* attribute, a method for creating new subcontexts, and a prop...
A :class:`ChainMap` incorporates the underlying mappings by reference. So, if one of the underlying mappings gets updated, those changes will be reflected in :class:`ChainMap`. All of the usual dictionary methods are supported. In addition, there is a *maps* attribute, a method for creating new subcontexts, and a prop...
python, official-docs, cpython, P0
Local_Trusted_Corpus
90322f3c-c43f-4f13-bbfc-1b598c5bc26c
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,379
supabase-export-v2
ef6081be500045d2
:class:`UserString` objects --------------------------- The class, :class:`UserString` acts as a wrapper around string objects. The need for this class has been partially supplanted by the ability to subclass directly from :class:`str`; however, this class can be easier to work with because the underlying string is acc...
trusted_official_docs
CPython Docs
:class:`UserString` objects --------------------------- The class, :class:`UserString` acts as a wrapper around string objects. The need for this class has been partially supplanted by the ability to subclass directly from :class:`str`; however, this class can be easier to work with because the underlying string is acc...
:class:`UserString` objects --------------------------- The class, :class:`UserString` acts as a wrapper around string objects. The need for this class has been partially supplanted by the ability to subclass directly from :class:`str`; however, this class can be easier to work with because the underlying string is acc...
python, official-docs, cpython, P0
Local_Trusted_Corpus
90ef89f9-3e37-4780-a5d6-bec2fc532e8b
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,199
supabase-export-v2
e6039bfa9730b78d
>>> d.appendleft('f') # add a new entry to the left side >>> d # show the representation of the deque deque(['f', 'g', 'h', 'i', 'j']) >>> d.pop() # return and remove the rightmost item 'j' >>> d.popleft() # return and remove the leftmost item 'f' >>> list(d) # list the contents of the deque ['g', 'h', 'i'] >>> d...
trusted_official_docs
CPython Docs
>>> d.appendleft('f') # add a new entry to the left side >>> d # show the representation of the deque deque(['f', 'g', 'h', 'i', 'j']) >>> d.pop() # return and remove the rightmost item 'j' >>> d.popleft() # return and remove the leftmost item 'f' >>> list(d) # list the contents of the deque ['g', 'h', 'i'] >>> d...
>>> d.appendleft('f') # add a new entry to the left side >>> d # show the representation of the deque deque(['f', 'g', 'h', 'i', 'j']) >>> d.pop() # return and remove the rightmost item 'j' >>> d.popleft() # return and remove the leftmost item 'f' >>> list(d) # list the contents of the deque ['g', 'h', 'i'] >>> d...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9409a86d-f785-4985-a866-f74e00c5d8c7
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,319
supabase-export-v2
42734b57b4aee641
A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=False)`` with ``(k := next(iter(d)), d.pop(k))`` which will return and remove the leftmost (first) item if it exists. * :class:`OrderedDict` has a :meth:`~OrderedDict.move_to_end` method to efficiently reposition an element to an endpoint.
trusted_official_docs
CPython Docs
A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=False)`` with ``(k := next(iter(d)), d.pop(k))`` which will return and remove the leftmost (first) item if it exists. * :class:`OrderedDict` has a :meth:`~OrderedDict.move_to_end` method to efficiently reposition an element to an endpoint.
A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=False)`` with ``(k := next(iter(d)), d.pop(k))`` which will return and remove the leftmost (first) item if it exists. * :class:`OrderedDict` has a :meth:`~OrderedDict.move_to_end` method to efficiently reposition an element to an endpoint.
python, official-docs, cpython, P0
Local_Trusted_Corpus
946a401c-9e7d-43dc-9308-8f02776396c1
CPython Docs
file://datasets/cpython/Doc/library/collections.rst
unknown
0f4e51ec-13d3-4fa3-b76a-63704d522acd
12,352
supabase-export-v2
da688ab4a3fdaf04
class MultiHitLRUCache: """ LRU cache that defers caching a result until it has been requested multiple times. To avoid flushing the LRU cache with one-time requests, we don't cache until a request has been made more than once.
trusted_official_docs
CPython Docs
class MultiHitLRUCache: """ LRU cache that defers caching a result until it has been requested multiple times. To avoid flushing the LRU cache with one-time requests, we don't cache until a request has been made more than once.
class MultiHitLRUCache: """ LRU cache that defers caching a result until it has been requested multiple times. To avoid flushing the LRU cache with one-time requests, we don't cache until a request has been made more than once.
python, official-docs, cpython, P0
Local_Trusted_Corpus