chunk_id
large_stringlengths
36
36
doc_type
large_stringclasses
2 values
category
large_stringclasses
17 values
document
large_stringclasses
50 values
version_raw
large_stringclasses
590 values
chunk_index
int64
0
262
text
large_stringlengths
11
5.69k
file_path
large_stringclasses
882 values
9e48ebf9-de09-55db-8861-5e62094c28a1
docs
python
python_stdtypes
39
141
>>> v = memoryview(data) >>> v.readonly False >>> v[0] = ord(b'z') >>> data bytearray(b'zbcefg') >>> v[1:4] = b'123' >>> data bytearray(b'z123fg') >>> v[2:3] = b'spam' Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: memoryview assi...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
b7273ace-4600-5ade-aa86-ea6a7d615e62
docs
python
python_stdtypes
39
142
Changed in version 3.4: memoryview is now registered automatically with [`collections.abc.Sequence`](collections.abc.html#collections.abc.Sequence "collections.abc.Sequence") Changed in version 3.5: memoryviews can now be indexed with tuple of integers. [`memoryview`](#memoryview "memoryview") has sev...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
98e7a466-0435-50f4-a237-5b95b0b0da32
docs
python
python_stdtypes
39
143
[`tolist()`](#memoryview.tolist "memoryview.tolist"), `v` and `w` are equal if `v.tolist() == w.tolist()`: ```None >>> import array >>> a = array.array('I', [1, 2, 3, 4, 5]) >>> b = array.array('d', [1.0, 2.0, 3.0, 4.0, 5.0]) >>> c = array.array('b', [5, 3, 1]) >...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
1c84f3fb-ad14-556c-a3a7-837d301da886
docs
python
python_stdtypes
39
144
... _fields_ = [("x", c_long), ("y", c_long)] ... >>> point = BEPoint(100, 200) >>> a = memoryview(point) >>> b = memoryview(point) >>> a == point False >>> a == b False ``` Note that, as with floating point numbers, `v is w` d...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
9b074c75-5ed7-558e-a148-840856112e80
docs
python
python_stdtypes
39
145
representation with all elements converted to bytes. [`tobytes()`](#memoryview.tobytes "memoryview.tobytes") supports all format strings, including those that are not in [`struct`](struct.html#module-struct "struct: Interpret bytes as packed binary data.") module syntax. New in version ...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
98681174-b5bc-5976-a38b-73c0f75b77dc
docs
python
python_stdtypes
39
146
New in version 3.5. Changed in version 3.8: Similar to [`bytes.hex()`](#bytes.hex "bytes.hex"), [`memoryview.hex()`](#memoryview.hex "memoryview.hex") now supports optional *sep* and *bytes\_per\_sep* parameters to insert separators between bytes in the hex output. `tolist`()[¶](#m...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
a6372f7a-c937-5536-93aa-b8dcbc247f66
docs
python
python_stdtypes
39
147
`toreadonly`()[¶](#memoryview.toreadonly "Permalink to this definition") : Return a readonly version of the memoryview object. The original memoryview object is unchanged. ```None >>> m = memoryview(bytearray(b'abc')) >>> mm = m.toreadonly() >>> mm.tolist() [89...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
6f4dfb56-c866-5cba-a417-98de066314e0
docs
python
python_stdtypes
39
148
dangling resources) as soon as possible. After this method has been called, any further operation on the view raises a [`ValueError`](exceptions.html#ValueError "ValueError") (except [`release()`](#memoryview.release "memoryview.release") itself which can be called multiple times): ...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
f9c215fe-e505-573e-9fd2-927274261133
docs
python
python_stdtypes
39
149
`cast`(*format*[, *shape*])[¶](#memoryview.cast "Permalink to this definition") : Cast a memoryview to a new format or shape. *shape* defaults to `[byte_length//new_itemsize]`, which means that the result view will be one-dimensional. The return value is a new memoryview, but the buffe...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
bb9cd844-5054-50bb-956f-3d437755b50a
docs
python
python_stdtypes
39
150
>>> len(x) 3 >>> x.nbytes 24 >>> y = x.cast('B') >>> y.format 'B' >>> y.itemsize 1 >>> len(y) 24 >>> y.nbytes 24 ``` Cast 1D/unsigned bytes to 1D/char: ```None >>> b = bytearray(b'zy...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
c91849ad-ba6f-5ce8-9188-4a931c3701b2
docs
python
python_stdtypes
39
151
>>> len(y) 2 >>> y.nbytes 48 >>> z = y.cast('b') >>> z.format 'b' >>> z.itemsize 1 >>> len(z) 48 >>> z.nbytes 48 ``` Cast 1D/unsigned long to 2D/unsigned long: ```None >>> buf = stru...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
b1a94057-9641-5f89-99ad-de59ab05946e
docs
python
python_stdtypes
39
152
`nbytes`[¶](#memoryview.nbytes "Permalink to this definition") : `nbytes == product(shape) * itemsize == len(m.tobytes())`. This is the amount of space in bytes that the array would use in a contiguous representation. It is not necessarily equal to `len(m)`: ```None >>> import...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
41bacb52-d878-5401-b0cc-8b7417350ae4
docs
python
python_stdtypes
39
153
`readonly`[¶](#memoryview.readonly "Permalink to this definition") : A bool indicating whether the memory is read only. `format`[¶](#memoryview.format "Permalink to this definition") : A string containing the format (in [`struct`](struct.html#module-struct "struct: Interpret bytes as packed binary ...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
1629013c-f456-56c7-b25b-8122b776d208
docs
python
python_stdtypes
39
154
>>> m.itemsize 2 >>> m[0] 32000 >>> struct.calcsize('H') == m.itemsize True ``` `ndim`[¶](#memoryview.ndim "Permalink to this definition") : An integer indicating how many dimensions of a multi-dimensional array the memory represents. `shap...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
9f1f26dc-1f30-53e5-9eea-fae9118462c7
docs
python
python_stdtypes
39
155
: Used internally for PIL-style arrays. The value is informational only. `c_contiguous`[¶](#memoryview.c_contiguous "Permalink to this definition") : A bool indicating whether the memory is C-[contiguous](../glossary.html#term-contiguous). New in version 3.3. `f_contiguous`[¶](#memoryview...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
10e0280d-5025-504a-91d0-1d779d0d5ec9
docs
python
python_stdtypes
39
156
computing mathematical operations such as intersection, union, difference, and symmetric difference. (For other containers see the built-in [`dict`](#dict "dict"), [`list`](#list "list"), and [`tuple`](#tuple "tuple") classes, and the [`collections`](collections.html#module-collections "collections: Container datatypes...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
fcad8693-11a1-5b2a-9d9b-679904d93270
docs
python
python_stdtypes
39
157
another set. The [`frozenset`](#frozenset "frozenset") type is immutable and [hashable](../glossary.html#term-hashable) — its contents cannot be altered after it is created; it can therefore be used as a dictionary key or as an element of another set. Non-empty sets (not frozensets) can be created by placing a comma-s...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
847f2fb2-ab54-5f90-9b57-a125b82d26f0
docs
python
python_stdtypes
39
158
* Use a comma-separated list of elements within braces: `{'jack', 'sjoerd'}` * Use a set comprehension: `{c for c in 'abracadabra' if c not in 'abc'}` * Use the type constructor: `set()`, `set('foobar')`, `set(['a', 'b', 'foo'])` Instances of [`set`](#set "set") and [`frozenset`](#frozenset "frozenset"...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
a42bc1a1-df5f-536d-9062-f5532c40cbf8
docs
python
python_stdtypes
39
159
: Test whether the set is a proper subset of *other*, that is, `set <= other and set != other`. `issuperset`(*other*)[¶](#frozenset.issuperset "Permalink to this definition") `set >= other` : Test whether every element in *other* is in the set. `set > other` : Test whether the s...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
ec156638-472e-519d-87c4-e223e0603711
docs
python
python_stdtypes
39
160
`symmetric_difference`(*other*)[¶](#frozenset.symmetric_difference "Permalink to this definition") `set ^ other` : Return a new set with elements in either the set or *other* but not both. `copy`()[¶](#frozenset.copy "Permalink to this definition") : Return a shallow copy of the set. Note...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
504b03a6-cab7-5d5c-89ea-105b6e17e8b4
docs
python
python_stdtypes
39
161
in favor of the more readable `set('abc').intersection('cbs')`. Both [`set`](#set "set") and [`frozenset`](#frozenset "frozenset") support set to set comparisons. Two sets are equal if and only if every element of each set is contained in the other (each is a subset of the other). A set is less than an...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
97ec0dd8-d171-5392-95bd-4a3d4ad390d4
docs
python
python_stdtypes
39
162
subsets of each other, so *all* of the following return `False`: `a<b`, `a==b`, or `a>b`. Since sets only define partial ordering (subset relationships), the output of the [`list.sort()`](#list.sort "list.sort") method is undefined for lists of sets. Set elements, like dictionary keys, must be [ha...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
61185227-e317-59f9-ab54-f6f92972a656
docs
python
python_stdtypes
39
163
`intersection_update`(*\*others*)[¶](#frozenset.intersection_update "Permalink to this definition") `set &= other & ...` : Update the set, keeping only elements found in it and all others. `difference_update`(*\*others*)[¶](#frozenset.difference_update "Permalink to this definition") `set -= ot...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
9cf59e83-1220-5370-9b81-17e257f72252
docs
python
python_stdtypes
39
164
: Remove element *elem* from the set if it is present. `pop`()[¶](#frozenset.pop "Permalink to this definition") : Remove and return an arbitrary element from the set. Raises [`KeyError`](exceptions.html#KeyError "KeyError") if the set is empty. `clear`()[¶](#frozenset.clear "Permalink to ...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
40aff4c0-9126-59f1-b88f-41567511de6d
docs
python
python_stdtypes
39
165
[`discard()`](#frozenset.discard "frozenset.discard") methods may be a set. To support searching for an equivalent frozenset, a temporary one is created from *elem*. ## Mapping Types — [`dict`](#dict "dict")[¶](#mapping-types-dict "Permalink to this headline") A [mapping](../glossary.html#term-mapping) object...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
e133f8c5-dab7-55b9-b505-8451b0d170f6
docs
python
python_stdtypes
39
166
not be used as keys. Numeric types used for keys obey the normal rules for numeric comparison: if two numbers compare equal (such as `1` and `1.0`) then they can be used interchangeably to index the same dictionary entry. (Note however, that since computers store floating-point numbers as approximations it is usually u...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
a8e14a6a-6f85-5542-9c1c-735734c37d8c
docs
python
python_stdtypes
39
167
If no positional argument is given, an empty dictionary is created. If a positional argument is given and it is a mapping object, a dictionary is created with the same key-value pairs as the mapping object. Otherwise, the positional argument must be an [iterable](../glossary.html#term-iterable) object. ...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
3273cda7-77ed-5dc3-8b57-a65dd5c33fb1
docs
python
python_stdtypes
39
168
`{"one": 1, "two": 2, "three": 3}`: ```None >>> a = dict(one=1, two=2, three=3) >>> b = {'one': 1, 'two': 2, 'three': 3} >>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3])) >>> d = dict([('two', 2), ('one', 1), ('three', 3)]) >>> e = dict({'three': 3, 'one': 1, 'two': 2}) >>> f = dict...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
ca292e2c-70e4-5793-bca9-efad4898ddcf
docs
python
python_stdtypes
39
169
If a subclass of dict defines a method [`__missing__()`](../reference/datamodel.html#object.__missing__ "object.__missing__") and *key* is not present, the `d[key]` operation calls that method with the key *key* as argument. The `d[key]` operation then returns or raises whatever is retur...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
172b1642-23a0-5bd1-b046-dade2d5fb52d
docs
python
python_stdtypes
39
170
>>> c['red'] += 1 >>> c['red'] 1 ``` The example above shows part of the implementation of [`collections.Counter`](collections.html#collections.Counter "collections.Counter"). A different `__missing__` method is used by [`collections.defaultdict`](collections.htm...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
bbc4a104-de5d-516a-8609-57aaf43701cd
docs
python
python_stdtypes
39
171
: Return a shallow copy of the dictionary. *classmethod* `fromkeys`(*iterable*[, *value*])[¶](#dict.fromkeys "Permalink to this definition") : Create a new dictionary with keys from *iterable* and values set to *value*. [`fromkeys()`](#dict.fromkeys "dict.fromkeys") is a class method that retu...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
45ad2ed6-064a-544b-8fe8-952ee4947061
docs
python
python_stdtypes
39
172
: Return a new view of the dictionary’s items (`(key, value)` pairs). See the [documentation of view objects](#dict-views). `keys`()[¶](#dict.keys "Permalink to this definition") : Return a new view of the dictionary’s keys. See the [documentation of view objects](#dict-views). `po...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
dc5c9723-4b80-586f-874a-2ec802406d8b
docs
python
python_stdtypes
39
173
[`popitem()`](#dict.popitem "dict.popitem") raises a [`KeyError`](exceptions.html#KeyError "KeyError"). Changed in version 3.7: LIFO order is now guaranteed. In prior versions, [`popitem()`](#dict.popitem "dict.popitem") would return an arbitrary key/value pair. `reversed(d)` : Retur...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
f279dd22-198f-5951-9e47-b40f9e13ba7a
docs
python
python_stdtypes
39
174
key/value pairs (as tuples or other iterables of length two). If keyword arguments are specified, the dictionary is then updated with those key/value pairs: `d.update(red=1, blue=2)`. `values`()[¶](#dict.values "Permalink to this definition") : Return a new view of the dictionary’s va...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
8a9de880-8515-5645-9d24-16f2546560bc
docs
python
python_stdtypes
39
175
either a [mapping](../glossary.html#term-mapping) or an [iterable](../glossary.html#term-iterable) of key/value pairs. The values of *other* take priority when *d* and *other* share keys. New in version 3.9. Dictionaries compare equal if and only if they have the same `(key, value)` pa...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
a66e56b6-cf0f-57fc-88a0-0bb955042cb2
docs
python
python_stdtypes
39
176
Changed in version 3.7: Dictionary order is guaranteed to be insertion order. This behavior was an implementation detail of CPython from 3.6. Dictionaries and dictionary views are reversible. ```None >>> d = {"one": 1, "two": 2, "three": 3, "four": 4} >>> d {'one': 1, 'two': 2, 'three': 3,...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
4654a092-43f1-5506-9c8a-8d6aad58a3e7
docs
python
python_stdtypes
39
177
[`dict.items()`](#dict.items "dict.items") are *view objects*. They provide a dynamic view on the dictionary’s entries, which means that when the dictionary changes, the view reflects these changes. Dictionary views can be iterated over to yield their respective data, and support membership tests: `len(dictview)` : ...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
cbd5cc72-17c4-529b-a0ab-6d9c9499bdc8
docs
python
python_stdtypes
39
178
Changed in version 3.7: Dictionary order is guaranteed to be insertion order. `x in dictview` : Return `True` if *x* is in the underlying dictionary’s keys, values or items (in the latter case, *x* should be a `(key, value)` tuple). `reversed(dictview)` : Return a reverse iterator over the keys, values or...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
310688c4-7167-5f9e-a6de-727d3e032d6e
docs
python
python_stdtypes
39
179
>>> dishes = {'eggs': 2, 'sausage': 1, 'bacon': 1, 'spam': 500} >>> keys = dishes.keys() >>> values = dishes.values() >>> # iteration >>> n = 0 >>> for val in values: ... n += val >>> print(n) 504 >>> # keys and values are iterated over in the same order (insertion order) >>> list(keys) ['eggs', 'sausage', 'bacon...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
0af4a5ae-0d06-5404-9fa9-af384fe9a3f8
docs
python
python_stdtypes
39
180
before the statement body is executed and exited when the statement ends: `contextmanager.``__enter__`()[¶](#contextmanager.__enter__ "Permalink to this definition") : Enter the runtime context and return either this object or another object related to the runtime context. The value returned by this method is bo...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
52d3f1f5-e4a8-5127-a165-4763e6d90cb2
docs
python
python_stdtypes
39
181
decimal context to a copy of the original decimal context and then return the copy. This allows changes to be made to the current decimal context in the body of the [`with`](../reference/compound_stmts.html#with) statement without affecting code outside the `with` statement. `contextmanager.``__exit__`...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
22794a48-1202-55fd-bd95-e034fb27bae9
docs
python
python_stdtypes
39
182
following the `with` statement. Otherwise the exception continues propagating after this method has finished executing. Exceptions that occur during execution of this method will replace any exception that occurred in the body of the `with` statement. The exception passed in should never be reraise...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
2691e5eb-fd7a-5138-9cea-d79ebd4c6b5b
docs
python
python_stdtypes
39
183
[`contextlib`](contextlib.html#module-contextlib "contextlib: Utilities for with-statement contexts.") module for some examples. Python’s [generator](../glossary.html#term-generator)s and the [`contextlib.contextmanager`](contextlib.html#contextlib.contextmanager "contextlib.contextmanager") decorator provide a conven...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
435230b9-0b6b-501b-a283-3b9a61806742
docs
python
python_stdtypes
39
184
define these methods must provide them as a normal Python accessible method. Compared to the overhead of setting up the runtime context, the overhead of a single class dictionary lookup is negligible. ## Generic Alias Type[¶](#generic-alias-type "Permalink to this headline") `GenericAlias` objects are generally creat...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
f63693dc-2cdb-50a0-a6d4-717935ca35e4
docs
python
python_stdtypes
39
185
A `GenericAlias` object acts as a proxy for a [generic type](../glossary.html#term-generic-type), implementing *parameterized generics*. For a container class, the argument(s) supplied to a [subscription](../reference/expressions.html#subscriptions) of the class may indicate the type(s) of the elements an object conta...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
2e78c7f4-6ea8-54b4-b27e-43a49c6ea2b0
docs
python
python_stdtypes
39
186
[re.Match](re.html#match-objects) object where the return values of `x.group(0)` and `x[0]` will both be of type [`str`](#str "str"). We can represent this kind of object in type annotations with the `GenericAlias` `re.Match[str]`. * If `y = re.search(b'bar', b'bar')`, (note the `b` for [`bytes`](#bytes "bytes"...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
8250e79b-aecd-509f-bc6c-bc586249b15f
docs
python
python_stdtypes
39
187
[`float`](functions.html#float "float") elements: ```None def average(values: list[float]) -> float: return sum(values) / len(values) ``` Another example for [mapping](../glossary.html#term-mapping) objects, using a [`dict`](#dict "dict"), which is a generic type expecting two type par...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
1a80ffb5-3d7b-5dc5-b70c-de38b52d05b0
docs
python
python_stdtypes
39
188
The Python runtime does not enforce [type annotations](../glossary.html#term-annotation). This extends to generic types and their type parameters. When creating a container object from a `GenericAlias`, the elements in the container are not checked against their type. For example, the following code is discouraged, but...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
89a464c8-bd78-5969-8ee6-55943dcc299e
docs
python
python_stdtypes
39
189
Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: There are no type variables left in dict[str] ``` However, such expressions are valid when [type variables](typing.html#generics) are used. The index must have as many elements as there are type variable items in the `GenericAlias` obj...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
52e6afc6-0776-5020-8c32-7420edba7018
docs
python
python_stdtypes
39
190
* [`collections.defaultdict`](collections.html#collections.defaultdict "collections.defaultdict") * [`collections.OrderedDict`](collections.html#collections.OrderedDict "collections.OrderedDict") * [`collections.Counter`](collections.html#collections.Counter "collections.Counter") * [`collections.ChainMap`](collections...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
5732ad79-eebb-52df-9d56-43ffbb443d9d
docs
python
python_stdtypes
39
191
* [`collections.abc.Iterable`](collections.abc.html#collections.abc.Iterable "collections.abc.Iterable") * [`collections.abc.Iterator`](collections.abc.html#collections.abc.Iterator "collections.abc.Iterator") * [`collections.abc.Generator`](collections.abc.html#collections.abc.Generator "collections.abc.Generator") * ...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
ad017fc2-9011-5ad1-aabb-34b339a85a96
docs
python
python_stdtypes
39
192
* [`collections.abc.Mapping`](collections.abc.html#collections.abc.Mapping "collections.abc.Mapping") * [`collections.abc.MutableMapping`](collections.abc.html#collections.abc.MutableMapping "collections.abc.MutableMapping") * [`collections.abc.Sequence`](collections.abc.html#collections.abc.Sequence "collections.abc.S...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
876b0450-3c48-591c-9985-36217a98d647
docs
python
python_stdtypes
39
193
* [`contextlib.AbstractContextManager`](contextlib.html#contextlib.AbstractContextManager "contextlib.AbstractContextManager") * [`contextlib.AbstractAsyncContextManager`](contextlib.html#contextlib.AbstractAsyncContextManager "contextlib.AbstractAsyncContextManager") * [`dataclasses.Field`](dataclasses.html#dataclasse...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
84caa211-aefc-58e4-8093-c35d9fc95293
docs
python
python_stdtypes
39
194
* [`shelve.DbfilenameShelf`](shelve.html#shelve.DbfilenameShelf "shelve.DbfilenameShelf") * [`shelve.Shelf`](shelve.html#shelve.Shelf "shelve.Shelf") * [`types.MappingProxyType`](types.html#types.MappingProxyType "types.MappingProxyType") * [`weakref.WeakKeyDictionary`](weakref.html#weakref.WeakKeyDictionary "weakref.W...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
1ceba3b2-df3c-59df-8040-a053c43acd90
docs
python
python_stdtypes
39
195
`genericalias.``__args__`[¶](#genericalias.__args__ "Permalink to this definition") : This attribute is a [`tuple`](#tuple "tuple") (possibly of length 1) of generic types passed to the original [`__class_getitem__()`](../reference/datamodel.html#object.__class_getitem__ "object.__class_getitem__") of the gen...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
22d83188-300c-547a-aba1-c1f61c521943
docs
python
python_stdtypes
39
196
: Introducing the ability to natively parameterize standard-library classes, provided they implement the special class method [`__class_getitem__()`](../reference/datamodel.html#object.__class_getitem__ "object.__class_getitem__"). [Generics](typing.html#generics), [user-defined generics](typing.html#user-de...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
255ed04d-af82-566e-8111-50300dec43d8
docs
python
python_stdtypes
39
197
Module attributes can be assigned to. (Note that the [`import`](../reference/simple_stmts.html#import) statement is not, strictly speaking, an operation on a module object; `import foo` does not require a module object named *foo* to exist, rather it requires an (external) *definition* for a module named *foo* somewher...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
e840fb4a-4c35-5cfa-9f25-080887a7f3ec
docs
python
python_stdtypes
39
198
'/usr/local/lib/pythonX.Y/os.pyc'>`. ### Classes and Class Instances[¶](#classes-and-class-instances "Permalink to this headline") See [Objects, values and types](../reference/datamodel.html#objects) and [Class definitions](../reference/compound_stmts.html#class) for these. ### Functions[¶](#functions "Permalink to ...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
4460bcba-978f-57dd-b99a-79af3bcea518
docs
python
python_stdtypes
39
199
instance methods. Built-in methods are described with the types that support them. If you access a method (a function defined in a class namespace) through an instance, you get a special object: a *bound method* (also called *instance method*) object. When called, it will add the `self` argument to the argument list. ...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
ed331d3c-4a54-58ae-ad7e-f8fce1476b0e
docs
python
python_stdtypes
39
200
attribute, you need to explicitly set it on the underlying function object: ```None >>> class C: ... def method(self): ... pass ... >>> c = C() >>> c.method.whoami = 'my name is method' # can't set on the method Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'meth...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
4ad024ce-a631-5fe3-be78-4297966d1067
docs
python
python_stdtypes
39
201
attribute. See also the [`code`](code.html#module-code "code: Facilities to implement read-eval-print loops.") module. Accessing `__code__` raises an [auditing event](sys.html#auditing) `object.__getattr__` with arguments `obj` and `"__code__"`. A code object can be executed or evaluated by passing it (instead of a s...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
ae94f192-1eef-56a6-8e6d-961208ee2ac1
docs
python
python_stdtypes
39
202
### The Null Object[¶](#the-null-object "Permalink to this headline") This object is returned by functions that don’t explicitly return a value. It supports no special operations. There is exactly one null object, named `None` (a built-in name). `type(None)()` produces the same singleton. It is written as `None`. ##...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
ee3d68b3-345f-5bc4-9c9c-ae196f07be8a
docs
python
python_stdtypes
39
203
asked to operate on types they don’t support. See [Comparisons](../reference/expressions.html#comparisons) for more information. There is exactly one `NotImplemented` object. `type(NotImplemented)()` produces the singleton instance. It is written as `NotImplemented`. ### Boolean Values[¶](#boolean-values "Permalink t...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
657e27a7-32da-5ccb-bad4-90ba09f8c380
docs
python
python_stdtypes
39
204
### Internal Objects[¶](#internal-objects "Permalink to this headline") See [The standard type hierarchy](../reference/datamodel.html#types) for this information. It describes stack frame objects, traceback objects, and slice objects. ## Special Attributes[¶](#special-attributes "Permalink to this headline") The imp...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
ccec60cb-683d-5f48-8551-1f906965c8a3
docs
python
python_stdtypes
39
205
: The name of the class, function, method, descriptor, or generator instance. `definition.``__qualname__`[¶](#definition.__qualname__ "Permalink to this definition") : The [qualified name](../glossary.html#term-qualified-name) of the class, function, method, descriptor, or generator instance. New in v...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
28b0be26-e728-53f4-84fd-e1c72dcccfe3
docs
python
python_stdtypes
39
206
method returns a list of all those references still alive. The list is in definition order. Example: ```None >>> int.__subclasses__() [<class 'bool'>] ``` ## Integer string conversion length limitation[¶](#integer-string-conversion-length-limitation "Permalink to this headline") CPython has a...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
a0a246a9-486e-54eb-b0dd-8fd92f3ec148
docs
python
python_stdtypes
39
207
have sub-quadratic complexity. Converting a large value such as `int('1' * 500_000)` can take over a second on a fast CPU. Limiting conversion size offers a practical way to avoid [CVE-2020-10735](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-10735). The limit is applied to the number of digit characters in...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
bd3f62f6-d2a6-5362-90d0-505fe22d2174
docs
python
python_stdtypes
39
208
ValueError: Exceeds the limit (4300) for integer string conversion: value has 8599 digits; use sys.set_int_max_str_digits() to increase the limit. >>> len(hex(i_squared)) 7144 >>> assert int(hex(i_squared), base=16) == i*i # Hexadecimal is unlimited. ``` The default limit is 4300 digits as provided in [`sys.int_info....
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
a1df42b9-786f-5a0f-9468-8c4d2919214e
docs
python
python_stdtypes
39
209
### Affected APIs[¶](#affected-apis "Permalink to this headline") The limitation only applies to potentially slow conversions between [`int`](functions.html#int "int") and [`str`](#str "str") or [`bytes`](#bytes "bytes"): * `int(string)` with default base 10. * `int(string, base)` for all bases that are not a power o...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
748fa750-2567-5707-9eb9-adac2479f2e5
docs
python
python_stdtypes
39
210
* [`str`](#str "str") to [`decimal.Decimal`](decimal.html#decimal.Decimal "decimal.Decimal"). ### Configuring the limit[¶](#configuring-the-limit "Permalink to this headline") Before Python starts up you can use an environment variable or an interpreter command line flag to configure the limit: * [`PYTHONINTMAXSTRDI...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
ecaba2b3-84b3-5959-b476-231e36c423bc
docs
python
python_stdtypes
39
211
`sys.int_info.default_max_str_digits` was used during initialization. From code, you can inspect the current limit and set a new one using these [`sys`](sys.html#module-sys "sys: Access system-specific parameters and functions.") APIs: * [`sys.get_int_max_str_digits()`](sys.html#sys.get_int_max_str_digits "sys.get_...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
44111393-dc21-51ae-b604-1ef6533b7741
docs
python
python_stdtypes
39
212
Setting a low limit *can* lead to problems. While rare, code exists that contains integer constants in decimal in their source that exceed the minimum threshold. A consequence of setting the limit is that Python source code containing decimal integer literals longer than the limit will encounter an error during parsing...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
cdd1551e-0743-556e-985c-eba437b4c813
docs
python
python_stdtypes
39
213
### Recommended configuration[¶](#recommended-configuration "Permalink to this headline") The default `sys.int_info.default_max_str_digits` is expected to be reasonable for most applications. If your application requires a different limit, set it from your main entry point using Python version agnostic code as these A...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
4322603c-faa8-5258-87c5-be620f5fe001
docs
python
python_stdtypes
39
214
Reference Manual ([Basic customization](../reference/datamodel.html#customization)). [2](#id2) : As a consequence, the list `[1, 2]` is considered equal to `[1.0, 2.0]`, and similarly for tuples. [3](#id4) : They must have since the parser can’t tell the type of the operands. 4([1](#id6),[2](#id7),[3](#i...
large_dataset/raw/docs/python/stdtypes/stdtypes_39.md
a05a6da1-687e-50d1-afe8-dae96f903549
docs
pytorch
pytorch_conv2d
20
0
# Conv2d¶ Source: https://docs.pytorch.org/docs/2.0/generated/torch.nn.Conv2d.html Version: 2.0 *class* torch.nn.Conv2d(*in\_channels*, *out\_channels*, *kernel\_size*, *stride=1*, *padding=0*, *dilation=1*, *groups=1*, *bias=True*, *padding\_mode='zeros'*, *device=None*, *dtype=None*)[[source]](../_modules/torch/nn/...
large_dataset/raw/docs/pytorch/conv2d/conv2d_20.md
85b429df-c986-5874-b78e-ef3c6a1ae385
docs
pytorch
pytorch_conv2d
20
1
out(Ni​,Coutj​​)=bias(Coutj​​)+k=0∑Cin​−1​weight(Coutj​​,k)⋆input(Ni​,k) where ⋆\star⋆ is the valid 2D [cross-correlation](https://en.wikipedia.org/wiki/Cross-correlation) operator, NNN is a batch size, CCC denotes a number of channels, HHH is a height of input planes in pixels, and WWW is width in...
large_dataset/raw/docs/pytorch/conv2d/conv2d_20.md
32fcb623-106a-5a20-9695-0818ec4f7ced
docs
pytorch
pytorch_conv2d
20
2
known as the à trous algorithm. It is harder to describe, but this [link](https://github.com/vdumoulin/conv_arithmetic/blob/master/README.md) has a nice visualization of what `dilation` does. * `groups` controls the connections between inputs and outputs. `in_channels` and `out_channels` must both...
large_dataset/raw/docs/pytorch/conv2d/conv2d_20.md
31562b09-9c74-570b-8e47-a745af6c1d59
docs
pytorch
pytorch_conv2d
20
3
> * a single `int` – in which case the same value is used for the height and width dimension > * a `tuple` of two ints – in which case, the first int is used for the height dimension, > and the second int for the width dimension Note When groups == in\_channels and out\_channels == K \* in\_chan...
large_dataset/raw/docs/pytorch/conv2d/conv2d_20.md
c4f6b828-7843-5c5f-b047-a7851210e4fa
docs
pytorch
pytorch_conv2d
20
4
In some circumstances when given tensors on a CUDA device and using CuDNN, this operator may select a nondeterministic algorithm to increase performance. If this is undesirable, you can try to make the operation deterministic (potentially at a performance cost) by setting `torch.backends.cudnn.deterministic = True`...
large_dataset/raw/docs/pytorch/conv2d/conv2d_20.md
900313b4-fffd-5bd9-900d-dbfc1fff54a6
docs
pytorch
pytorch_conv2d
20
5
* **out\_channels** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.11)")) – Number of channels produced by the convolution * **kernel\_size** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.11)") *or* [*tuple*](https://docs.python.org/3/library/...
large_dataset/raw/docs/pytorch/conv2d/conv2d_20.md
528ffac2-bb98-5825-a4c6-5c75fd8e085c
docs
pytorch
pytorch_conv2d
20
6
* **padding\_mode** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.11)")*,* *optional*) – `'zeros'`, `'reflect'`, `'replicate'` or `'circular'`. Default: `'zeros'` * **dilation** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.11)") *or...
large_dataset/raw/docs/pytorch/conv2d/conv2d_20.md
b412ecc4-1045-5f14-91d2-9348c8a27daa
docs
pytorch
pytorch_conv2d
20
7
: * Input: (N,Cin,Hin,Win)(N, C\_{in}, H\_{in}, W\_{in})(N,Cin​,Hin​,Win​) or (Cin,Hin,Win)(C\_{in}, H\_{in}, W\_{in})(Cin​,Hin​,Win​) * Output: (N,Cout,Hout,Wout)(N, C\_{out}, H\_{out}, W\_{out})(N,Cout​,Hout​,Wout​) or (Cout,Hout,Wout)(C\_{out}, H\_{out}, W\_{out})(Cout​,Hout​,Wout​), where H...
large_dataset/raw/docs/pytorch/conv2d/conv2d_20.md
0926cf87-8a01-5085-bdb7-0a13d82a0f5b
docs
pytorch
pytorch_conv2d
20
8
: * **weight** ([*Tensor*](../tensors.html#torch.Tensor "torch.Tensor")) – the learnable weights of the module of shape (out\_channels,in\_channelsgroups,(\text{out\\_channels}, \frac{\text{in\\_channels}}{\text{groups}},(out\_channels,groupsin\_channels​, kernel\_size[0],kernel\_size[1])\text...
large_dataset/raw/docs/pytorch/conv2d/conv2d_20.md
a581515d-b257-58c1-8f33-806db1c53eec
docs
pytorch
pytorch_conv2d
20
9
k=groupsCin∗∏i=01kernel\_size[i]k = \frac{groups}{C\_\text{in} \* \prod\_{i=0}^{1}\text{kernel\\_size}[i]}k=Cin​∗∏i=01​kernel\_size[i]groups​ Examples ```None >>> # With square kernels and equal stride >>> m = nn.Conv2d(16, 33, 3, stride=2) >>> # non-square kernels and unequal stride and...
large_dataset/raw/docs/pytorch/conv2d/conv2d_20.md
cde55629-27b0-5198-b2b0-0667631ac1ab
docs
pytorch
pytorch_conv2d
20
10
Built with [Sphinx](http://sphinx-doc.org/) using a [theme](https://github.com/rtfd/sphinx_rtd_theme) provided by [Read the Docs](https://readthedocs.org).
large_dataset/raw/docs/pytorch/conv2d/conv2d_20.md
b4a463d6-766b-59c0-83a1-80b03665db6f
docs
pytorch
pytorch_conv2d
21
0
# Conv2d¶ Source: https://docs.pytorch.org/docs/2.1/generated/torch.nn.Conv2d.html Version: 2.1 *class* torch.nn.Conv2d(*in\_channels*, *out\_channels*, *kernel\_size*, *stride=1*, *padding=0*, *dilation=1*, *groups=1*, *bias=True*, *padding\_mode='zeros'*, *device=None*, *dtype=None*)[[source]](../_modules/torch/nn/...
large_dataset/raw/docs/pytorch/conv2d/conv2d_21.md
724acf35-c375-5a1d-9248-8ed31e9b534b
docs
pytorch
pytorch_conv2d
21
1
out(Ni​,Coutj​​)=bias(Coutj​​)+k=0∑Cin​−1​weight(Coutj​​,k)⋆input(Ni​,k) where ⋆\star⋆ is the valid 2D [cross-correlation](https://en.wikipedia.org/wiki/Cross-correlation) operator, NNN is a batch size, CCC denotes a number of channels, HHH is a height of input planes in pixels, and WWW is width in...
large_dataset/raw/docs/pytorch/conv2d/conv2d_21.md
630128d1-887a-50c4-9a51-f43d9b1e4f1e
docs
pytorch
pytorch_conv2d
21
2
known as the à trous algorithm. It is harder to describe, but this [link](https://github.com/vdumoulin/conv_arithmetic/blob/master/README.md) has a nice visualization of what `dilation` does. * `groups` controls the connections between inputs and outputs. `in_channels` and `out_channels` must both...
large_dataset/raw/docs/pytorch/conv2d/conv2d_21.md
643b2a78-92de-5c13-be4f-95cfc0115a44
docs
pytorch
pytorch_conv2d
21
3
> * a single `int` – in which case the same value is used for the height and width dimension > * a `tuple` of two ints – in which case, the first int is used for the height dimension, > and the second int for the width dimension Note When groups == in\_channels and out\_channels == K \* in\_chan...
large_dataset/raw/docs/pytorch/conv2d/conv2d_21.md
0c769dd1-0636-5d6d-a4dc-892618e4df88
docs
pytorch
pytorch_conv2d
21
4
In some circumstances when given tensors on a CUDA device and using CuDNN, this operator may select a nondeterministic algorithm to increase performance. If this is undesirable, you can try to make the operation deterministic (potentially at a performance cost) by setting `torch.backends.cudnn.deterministic = True`...
large_dataset/raw/docs/pytorch/conv2d/conv2d_21.md
c8fd7e4e-dd8d-5736-9338-33083af3bfa0
docs
pytorch
pytorch_conv2d
21
5
* **kernel\_size** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.12)") *or* [*tuple*](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.12)")) – Size of the convolving kernel * **stride** ([*int*](https://docs.python.org/3/library/functions.html#int "(in...
large_dataset/raw/docs/pytorch/conv2d/conv2d_21.md
aa0b660d-e260-5459-87f6-1b9a1b996fea
docs
pytorch
pytorch_conv2d
21
6
`'replicate'` or `'circular'`. Default: `'zeros'` * **dilation** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.12)") *or* [*tuple*](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.12)")*,* *optional*) – Spacing between kernel elements. Default: 1 ...
large_dataset/raw/docs/pytorch/conv2d/conv2d_21.md
6763a697-d900-5821-ad6e-8aed1b6261b6
docs
pytorch
pytorch_conv2d
21
7
* Output: (N,Cout,Hout,Wout)(N, C\_{out}, H\_{out}, W\_{out})(N,Cout​,Hout​,Wout​) or (Cout,Hout,Wout)(C\_{out}, H\_{out}, W\_{out})(Cout​,Hout​,Wout​), where Hout=⌊Hin+2×padding[0]−dilation[0]×(kernel\_size[0]−1)−1stride[0]+1⌋H\_{out} = \left\lfloor\frac{H\_{in} + 2 \times \text{padding}[0] - \text{...
large_dataset/raw/docs/pytorch/conv2d/conv2d_21.md
6ee8ab8a-f6ad-5fc5-ad7d-ae4bb61dba41
docs
pytorch
pytorch_conv2d
21
8
(out\_channels,in\_channelsgroups,(\text{out\\_channels}, \frac{\text{in\\_channels}}{\text{groups}},(out\_channels,groupsin\_channels​, kernel\_size[0],kernel\_size[1])\text{kernel\\_size[0]}, \text{kernel\\_size[1]})kernel\_size[0],kernel\_size[1]). The values of these weights are sample...
large_dataset/raw/docs/pytorch/conv2d/conv2d_21.md
4eb517bd-6aa6-5485-a34f-2d3d70a08201
docs
pytorch
pytorch_conv2d
21
9
>>> # With square kernels and equal stride >>> m = nn.Conv2d(16, 33, 3, stride=2) >>> # non-square kernels and unequal stride and with padding >>> m = nn.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2)) >>> # non-square kernels and unequal stride and with padding and dilation >>> m = nn.Con...
large_dataset/raw/docs/pytorch/conv2d/conv2d_21.md
f8a7313e-a331-541f-b6fa-c462744210bd
docs
pytorch
pytorch_conv2d
22
0
# Conv2d¶ Source: https://docs.pytorch.org/docs/2.2/generated/torch.nn.Conv2d.html Version: 2.2 *class* torch.nn.Conv2d(*in\_channels*, *out\_channels*, *kernel\_size*, *stride=1*, *padding=0*, *dilation=1*, *groups=1*, *bias=True*, *padding\_mode='zeros'*, *device=None*, *dtype=None*)[[source]](../_modules/torch/nn/...
large_dataset/raw/docs/pytorch/conv2d/conv2d_22.md
f114cba4-a993-513e-ad57-6befb60e77fd
docs
pytorch
pytorch_conv2d
22
1
out(Ni​,Coutj​​)=bias(Coutj​​)+k=0∑Cin​−1​weight(Coutj​​,k)⋆input(Ni​,k) where ⋆\star⋆ is the valid 2D [cross-correlation](https://en.wikipedia.org/wiki/Cross-correlation) operator, NNN is a batch size, CCC denotes a number of channels, HHH is a height of input planes in pixels, and WWW is width in...
large_dataset/raw/docs/pytorch/conv2d/conv2d_22.md
629dc782-108a-51c1-a0c4-b723071de4dc
docs
pytorch
pytorch_conv2d
22
2
known as the à trous algorithm. It is harder to describe, but this [link](https://github.com/vdumoulin/conv_arithmetic/blob/master/README.md) has a nice visualization of what `dilation` does. * `groups` controls the connections between inputs and outputs. `in_channels` and `out_channels` must both...
large_dataset/raw/docs/pytorch/conv2d/conv2d_22.md
8073ab3e-44db-5fb2-a0da-f8a6f7e6c0a3
docs
pytorch
pytorch_conv2d
22
3
> * a single `int` – in which case the same value is used for the height and width dimension > * a `tuple` of two ints – in which case, the first int is used for the height dimension, > and the second int for the width dimension Note When groups == in\_channels and out\_channels == K \* in\_chan...
large_dataset/raw/docs/pytorch/conv2d/conv2d_22.md
755d7e23-e4a6-52af-ac48-9adbe5e48ec0
docs
pytorch
pytorch_conv2d
22
4
In some circumstances when given tensors on a CUDA device and using CuDNN, this operator may select a nondeterministic algorithm to increase performance. If this is undesirable, you can try to make the operation deterministic (potentially at a performance cost) by setting `torch.backends.cudnn.deterministic = True`...
large_dataset/raw/docs/pytorch/conv2d/conv2d_22.md