Search
Searching for multiple words only shows matches that contain all words.
Search Results
Search finished, found 61 pages matching the search query.
- Glossary
__slots__
- PyType_Spec.slots (C member, in Type Objects)
- Isolating Extension Modules
...class definition in a new API, you are likely to unintentionally change a few details (e.g. pickleability or inherited slots). Always test the details that are important to you. Watch out for the following two points in particular (but not...
- Type Objects
...ence, the Examples section provides at-a-glance insight into the meaning and use of PyTypeObject. Quick Reference “tp slots” PyTypeObject Slot [1] Type special methods/attrs Info [2] O T D I <R> tp_name const char * __name_...
- Unicode Objects and Codecs
...exception was raised by the codec. Use CP_ACP code page to get the MBCS encoder. Added in version 3.3. Methods & Slots Methods and Slot Functions The following APIs are capable of handling Unicode objects and strings on input (we...
- object.__slots__ (Python data, in 3. Data model)
- PyModuleDef.m_slots (C member, in Module Objects)
- 3. Data model > __slots__
3.3.2.4. __slots__ __slots__ allow us to explicitly declare data members (like properties) and deny the creation of __dict__ and __weakref__ (unless explicitly declared in __slots__ or available in a parent.) The space saved over using __d...
- Type Objects > sub-slots
sub-slots Slot Type special methods am_await unaryfunc __await__ am_aiter unaryfunc __aiter__ am_anext unaryfunc __anext__ am_send sendfunc nb_add binaryfunc __add__ __radd__ nb_inplace_add binaryfunc __iadd__ nb_subtrac...
- Type Objects > “tp slots”
“tp slots” PyTypeObject Slot [1] Type special methods/attrs Info [2] O T D I <R> tp_name const char * __name__ X X tp_basicsize Py_ssize_t X X X tp_itemsize Py_ssize_t X X tp_dealloc destructor X X X tp_vectorca...
- What’s New In Python 3.10 > __slots__
__slots__ Added slots parameter in dataclasses.dataclass() decorator. (Contributed by Yurii Karabas in bpo-42269)
dataclasses
— Data Classes...taclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False) This function is a decorator that is used to add generated special methods to classes,...
dis
— Disassembler for Python bytecode...d in version 3.13. DELETE_FAST(var_num) Deletes local co_varnames[var_num]. MAKE_CELL(i) Creates a new cell in slot i. If that slot is nonempty then that value is stored into the new cell. Added in version 3.11. LOAD_DEREF(i...
errno
— Standard errno system symbols...errno.EXFULL Exchange full errno.ENOANO No anode errno.EBADRQC Invalid request code errno.EBADSLT Invalid slot errno.EDEADLOCK File locking deadlock error errno.EBFONT Bad font file format errno.ENOSTR Device not a...
functools
— Higher-order functions and operations on callable objects...ince the __dict__ attributes on type instances are read-only proxies for the class namespace), and those that specify __slots__ without including __dict__ as one of the defined slots (as such classes don’t provide a __dict__ attribute at al...
gc
— Garbage Collector interface....4, this list should be empty most of the time, except when using instances of C extension types with a non-NULL tp_del slot. If DEBUG_SAVEALL is set, then all unreachable objects will be added to this list rather than freed. Changed in ve...
importlib
— The implementation ofimport
...create_module() method must return None or a type for which its __class__ attribute can be mutated along with not using slots. Finally, modules which substitute the object placed into sys.modules will not work as there is no way to properly...
inspect
— Inspect live objects...e unable to find instance members. Added in version 3.2. getattr_static() does not resolve descriptors, for example slot descriptors or getset descriptors on objects implemented in C. The descriptor object is returned instead of the und...
multiprocessing
— Process-based parallelism...If the optional argument block is True (the default) and timeout is None (the default), block if necessary until a free slot is available. If timeout is a positive number, it blocks at most timeout seconds and raises the queue.Full excepti...
pickle
— Python object serialization...the instance, instead of a default state. There are several cases: For a class that has no instance __dict__ and no __slots__, the default state is None. For a class that has an instance __dict__ and no __slots__, the default state is sel...
queue
— A synchronized queue class...item into the queue. If optional args block is true and timeout is None (the default), block if necessary until a free slot is available. If timeout is a positive number, it blocks at most timeout seconds and raises the Full exception if...
types
— Dynamic type creation and names for built-in types...rpose as the property type, but for classes defined in extension modules. In addition, when a class is defined with a __slots__ attribute, then for each slot, an instance of MemberDescriptorType will be added as an attribute on the class. T...
typing
— Support for type hints...they would have on the @dataclasses.dataclass decorator: init, eq, order, unsafe_hash, frozen, match_args, kw_only, and slots. It must be possible for the value of these arguments (True or False) to be statically evaluated. The arguments to...
- 2. Defining Extension Types: Tutorial
...shouldn’t call tp_init explicitly, as the interpreter will do it itself. The tp_new implementation calls the tp_alloc slot to allocate memory: self = (CustomObject *) type->tp_alloc(type, 0); Since memory allocation may fail, we must ch...
- 3. Configure Python
...al calls; Frames pushed; Frame object created; Eval calls: vector, generator, legacy, function VECTORCALL, build class, slot, function “ex”, API, method. Object: incref and decref; interpreter incref and decref; allocations: all, 512 byt...
- 3. Data model
...ject used to store an object’s (writable) attributes. Not all instances have a __dict__ attribute; see the section on __slots__ for more details. 3.2.12. I/O objects (also known as file objects) A file object represents an open file....
- 3. Defining Extension Types: Assorted Topics
...ve been defined as optional blocks of handlers referenced by the type object. For newer protocols there are additional slots in the main type object, with a flag bit being set to indicate that the slots are present and should be checked by...
- 6. Expressions
...keyword arguments are present, they are first converted to positional arguments, as follows. First, a list of unfilled slots is created for the formal parameters. If there are N positional arguments, they are placed in the first N slots....
- Built-in Types
...a tree structure which supports both breadth-first and depth-first traversal.) This method corresponds to the tp_iter slot of the type structure for Python objects in the Python/C API. The iterator objects themselves are required to sup...
- C API Extension Support for Free Threading
...-Phase Initialization Extensions that use multi-phase initialization (i.e., PyModuleDef_Init()) should add a Py_mod_gil slot in the module definition. If your extension supports older versions of CPython, you should guard the slot with a P...
- Call Protocol
...tp_call and vectorcall. The tp_call Protocol Instances of classes that set tp_call are callable. The signature of the slot is: PyObject *tp_call(PyObject *callable, PyObject *args, PyObject *kwargs); A call is made using a tuple for the...
- Changelog
...t output or returning incorrect value from raw binary write() when writing to console on Windows. gh-123935: Fix parent slots detection for dataclasses that inherit from classes with __dictoffset__. gh-122765: Fix unbalanced quote errors oc...
- Common Object Structures
...be loaded in place of existing definitions. Without METH_COEXIST, the default is to skip repeated definitions. Since slot wrappers are loaded before the method table, the existence of a sq_contains slot, for example, would generate a wra...
- Concrete Objects Layer
...ape Codecs Raw-Unicode-Escape Codecs Latin-1 Codecs ASCII Codecs Character Map Codecs MBCS codecs for Windows Methods & Slots Methods and Slot Functions Tuple Objects Struct Sequence Objects List Objects Container Objects Dictiona...
- Descriptor Guide
...Python Equivalents Properties Functions and methods Kinds of methods Static methods Class methods Member objects and __slots__ Descriptors let objects customize attribute lookup, storage, and deletion. This guide has four major secti...
- Logging Cookbook
...xample shows how to log to a Qt GUI. This introduces a simple QtHandler class which takes a callable, which should be a slot in the main thread that does GUI updates. A worker thread is also created to show how you can log to the GUI from b...
- Module Objects
...e of module-level functions, described by PyMethodDef values. Can be NULL if no functions are present. PyModuleDef_Slot *m_slots An array of slot definitions for multi-phase initialization, terminated by a {0, NULL} entry. When using s...
- Number Protocol
...Index_Check(PyObject *o) Part of the Stable ABI since version 3.8.Returns 1 if o is an index integer (has the nb_index slot of the tp_as_number structure filled in), and 0 otherwise. This function always succeeds....
- Object Implementation Support
...tributes of extension types Member flags Member types Defining Getters and Setters Type Objects Quick Reference “tp slots” sub-slots slot typedefs PyTypeObject Definition PyObject Slots PyVarObject Slots PyTypeObject Slots Static Type...
- Object Protocol
...ence. Part of the Stable ABI.Generic attribute getter function that is meant to be put into a type object’s tp_getattro slot. It looks for a descriptor in the dictionary of classes in the object’s MRO as well as an attribute in the object’...
- PyHash API
...ash_t PyObject_GenericHash(PyObject *obj) Generic hashing function that is meant to be put into a type object’s tp_hash slot. Its result only depends on the object’s identity. CPython implementation detail: In CPython, it is equivalent to...
- PyModuleDef.m_slots.m_reload (C member, in Module Objects)
- Python Documentation contents
...yncio argparse array asynchat, asyncore, smtpd base64 bdb bisect codecs collections.abc contextlib curses dataclasses __slots__ Keyword-only fields distutils doctest encodings enum fileinput faulthandler gc glob hashlib hmac IDLE and idle...
- Queues
...drops to zero, join() unblocks. async put(item) Put an item into the queue. If the queue is full, wait until a free slot is available before adding the item. Raises QueueShutDown if the queue has been shut down. put_nowait(item) Put...
- Type Objects
...peObject *type, Py_ssize_t nitems) Return value: New reference. Part of the Stable ABI.Generic handler for the tp_alloc slot of a type object. Use Python’s default memory allocation mechanism to allocate a new instance and initialize all i...
- What’s New in Python 2.0
...stom implementation for in. Additionally, new built-in objects written in C can define what in means for them via a new slot in the sequence protocol. Earlier versions of Python used a recursive algorithm for deleting objects. Deeply nested...
- What’s New in Python 2.1
...thod and can return any Python object. There are also corresponding changes of interest to C programmers; there’s a new slot tp_richcmp in type objects and an API for performing a given rich comparison. I won’t cover the C API here, but wi...
- What’s New in Python 2.2
...tes can now have docstrings, too. The list of legal attributes for an instance can be limited to a particular set using slots, making it possible to safeguard against typos and perhaps make more optimizations possible in future versions of...
- What’s New in Python 2.4
...of a number of arguments. (Contributed by Greg Chapman.) A new method flag, METH_COEXIST, allows a function defined in slots to co-exist with a PyCFunction having the same name. This can halve the access time for a method such as set.__co...
- What’s New in Python 2.5
...check that the type returned is correct, and raises a TypeError if this requirement isn’t met. A corresponding nb_index slot was added to the C-level PyNumberMethods structure to let C extensions implement this protocol. PyNumber_Index(obj)...
- What’s New in Python 2.6
...xtensions that import other modules. C API: extension data types that shouldn’t be hashable should define their tp_hash slot to PyObject_HashNotImplemented(). The socket module exception socket.error now inherits from IOError. Previously i...
- What’s New In Python 3.0
..._ImportModule() but won’t block on the import lock (returning an error instead). Renamed the boolean conversion C-level slot and method: nb_nonzero is now nb_bool. Removed METH_OLDARGS and WITH_CYCLE_GC from the C API. Performance The ne...
- What’s New In Python 3.10
...le if they are provided by the underlying curses library. (Contributed by Zackery Spytz in bpo-39273.) dataclasses __slots__ Added slots parameter in dataclasses.dataclass() decorator. (Contributed by Yurii Karabas in bpo-42269) Keywor...
- What’s New In Python 3.11
...Dict, collections.deque, weakref.WeakSet, and datetime.tzinfo now copies and pickles instance attributes implemented as slots. This change has an unintended side effect: It trips up a small minority of existing Python projects not expecting...
- What’s New In Python 3.12
...romFormatV(). (Contributed by Philip Georgi in gh-95504.) Extension classes wanting to add a __dict__ or weak reference slot should use Py_TPFLAGS_MANAGED_DICT and Py_TPFLAGS_MANAGED_WEAKREF instead of tp_dictoffset and tp_weaklistoffset, r...
- What’s New In Python 3.13
...() sets ssl.VERIFY_X509_PARTIAL_CHAIN and ssl.VERIFY_X509_STRICT as default flags. C API improvements: The Py_mod_gil slot is now used to indicate that an extension module supports running with the GIL disabled. The PyTime C API has been...
- What’s New In Python 3.3
...rgument (that defaults to False to ensure that it caches values of different types that compare equal in separate cache slots. (Contributed by Raymond Hettinger in bpo-13227.) gc It is now possible to register callbacks invoked by the ga...
- What’s New In Python 3.4
...Argument Clinic DSLPEP written and implemented by Larry Hastings. Other Build and C API Changes The new PyType_GetSlot() function has been added to the stable ABI, allowing retrieval of function pointers from named type slots when usi...
- What’s New In Python 3.5
...plication. (Contributed by Benjamin Peterson in bpo-21176. See also PEP 465 for details.) The PyTypeObject.tp_finalize slot is now part of the stable ABI. Windows builds now require Microsoft Visual C++ 14.0, which is available as part of...
- What’s New In Python 3.8
...t. (Contributed by Terry J. Reedy in bpo-37765.) inspect The inspect.getdoc() function can now find docstrings for __slots__ if that attribute is a dict where the values are docstrings. This provides documentation options similar to what...
- What’s New In Python 3.9
...7.1 16.4 16.9 read_instancevar 32.4 33.1 28.0 26.3 25.4 25.3 read_instancevar_slots 27.8 31.3 20.8 20.8 20.2 20.5 read_namedtuple 73.8 57.5 45.0 4...