Notice: While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience.
...StructSequence_Field (name, doc) PyStructSequence_Desc (name, doc, fields, sequence) PyType_Slot (see below) PyType_Spec (see below) The accessor macros to these fields (Py_REFCNT, Py_TYPE, Py_SIZE) are also available to applications. The following types are available, but opaque (i.e. incomplete): PyThreadState PyInterpreterState struct _frame struct symtable struct _node PyWeakReference PyLongObject PyTypeObject Type Objects The structure of type objects is not available to applications; ...
...definitions above generate the following C structure type: typedef struct _stmt *stmt_ty; struct _stmt { enum { FunctionDef_kind=1, Return_kind=2, Yield_kind=3 } kind; union { struct { identifier name; arguments_ty args; asdl_seq *body; } FunctionDef; struct { expr_ty value; } Return; struct { expr_ty v...
...struct FooObject{ PyObject_HEAD int data; }; PyObject *foo(struct FooObject*f){ return (PyObject*)f; } int bar(){ struct FooObject *f = malloc(sizeof(struct FooObject)); struct PyObject *o = foo(f); f->ob_refcnt = 0; o->ob_refcnt = 1; return f->ob_refcnt; } The problem here is that the storage is both accessed as if it where struct PyObject, and as struct FooObject. Historically, compilers did not have any problems with this code. However, modern compilers use that clause a...
...struct xxstate{ PyObject *ErrorObject; PyObject *Xxo_Type; }; #define xxstate(o) ((struct xxstate*)PyModule_GetState(o)) static int xx_traverse(PyObject *m, visitproc v, void *arg) { Py_VISIT(xxstate(m)->ErrorObject); Py_VISIT(xxstate(m)->Xxo_Type); return 0; } static int xx_clear(PyObject *m) { Py_CLEAR(xxstate(m)->ErrorObject); Py_CLEAR(xxstate(m)->Xxo_Type); return 0; } static struct PyModuleDef xxmodule = { {}, /* m_base */ sizeof(st...
...struct memory layouts) – usually for performance reasons. The Limited API is not limited to CPython. Other implementations are encouraged to implement it and help drive its design. Specification To make the Stable ABI more useful and robust, the following changes are proposed. Stable ABI Manifest All members of the Stable ABI – functions, typedefs, structs, data, macros, and constants – will be explicitly listed in a single "manifest" file, Misc/stable_abi.txt. For structs, any fields that u...
Version: None
Released: May 17, 2022
This is the thirteenth and final regular maintenance release of Python 3.9 Note: The release you're looking at is Python 3.9.13, a bugfix release for the legacy 3.9 series. Python 3.11 is now the latest feature release series of Python 3. Get the latest release of 3.11.x here. According …
View Release Notes
...definition: typedef union { /* ensure 24 bytes */ unsigned char uc[24]; /* two Py_hash_t for FNV */ struct { Py_hash_t prefix; Py_hash_t suffix; } fnv; #ifdef PY_UINT64_T /* two uint64 for SipHash24 */ struct { PY_UINT64_T k0; PY_UINT64_T k1; } siphash; #endif /* a different (!) Py_hash_t for small string optimization */ struct { unsigned char padding[16]; Py_hash_t suffix; } djbx33a; struct { ...
...structure variable when processing a non-expression, e.g. a function definition, the last assigned name remains active until either the next assignment or the next occurrence of a docstring. This can lead to cases where the docstring and assignment may be separated by other expressions: class C: "C doc string" b = 2 def x(self): "C.x doc string" y = 3 return 1 "b's doc string" Since the definition of method "x" currently does not reset the used assi...
...struct memberlist (defined in structmember.h) or a struct getsetlist (defined in descrobject.h). The struct memberlist is an old mechanism put to new use: each attribute has a descriptor record including its name, an enum giving its type (various C types are supported as well as PyObject *), an offset from the start of the instance, and a read-only flag. The struct getsetlist mechanism is new, and intended for cases that don't fit in that mold, because they either require additional checking, o...
Released: June 9, 2020
This is a beta preview of Python 3.9 Python 3.9 is still in development. This release, 3.9.0b3, is the third of five planned beta release previews. Beta release previews are intended to give the wider community the opportunity to test new features and bug fixes and to prepare their projects …
...struct holds the settings that may vary between the main interpreter and subinterpreters. For the main interpreter, these settings are automatically populated by Py_InitializeMainInterpreter(). typedef struct { PyBoolObject *is_main_interpreter; /* Easily check for subinterpreters */ } PyInterpreterConfig; As these structs consist solely of object pointers, no explicit initializer definitions are needed - C99's default initialization of struct memory to zero is sufficient. Completing ...
WARNING: this release has a known regression See BPO-40924 for details. Use Python 3.9.0b3 or newer instead, please. This is a beta preview of Python 3.9 Python 3.9 is still in development. This release, 3.9.0b2, is the second of four planned beta release previews. Beta release previews are intended to …
PEP 754 -- IEEE 754 Floating Point Special Values PEP:754 Title:IEEE 754 Floating Point Special Values Author:Gregory R. Warnes <gregory_r_warnes at groton.pfizer.com> (Pfizer, Inc.) Status:Rejected Type:Standards Track Created:28-Mar-2003 Python-Version:2.3 Post-History: Contents Rejection Notice Abstract Rationale API Definition Constants Functions Example Implementation References Copyright Rejection Notice This PEP has been rejected. After sitting open for four ...
...struction process earlier, the new system allows the ordering or other early artifacts of construction to be preserved and examined. There proposed metaclass mechanism also supports a number of other interesting use cases beyond preserving the ordering of declarations. One use case is to insert symbols into the namespace of the class body which are only valid during class construction. An example of this might be "field constructors", small functions that are used in the creation of class member...
...structor function to free the memory when the reference count goes to zero. The special implementation of slicing for the bytes object allows multiple bytes objects to refer to the same pointer/destructor. As such, a refcount will be kept on the actual pointer/destructor. This refcount is separate from the refcount typically associated with Python objects. XXX: It may be desirable to expose the inner refcounted object as an actual Python object. If a good use case arises, it should be possible...
...structures. Some special semantics apply to make the use of these methods, and the mixing of Python instance objects and C types, as unsurprising as possible. In the generic case of x <augop> y (or a similar case using the PyNumber_InPlace API functions) the principal object being operated on is x. This differs from normal binary operations, where x and y could be considered co-operating, because unlike in binary operations, the operands in an in-place operation cannot be swapped. Howev...
...structure extending PyCFunctionObject will be added to hold the extra information: typedef struct { PyCFunctionObject func; PyTypeObject *mm_class; /* Passed as 'defining_class' arg to the C func */ } PyCMethodObject; The PyCFunction implementation will pass mm_class into a PyCMethod C function when it finds the METH_METHOD flag being set. A new macro PyCFunction_GET_CLASS(cls) will be added for easier access to mm_class. C methods may continue to use the other METH_* signatures if the...
...definition of Py_tss_t to depend on the underlying implementation. Since the existing TLS API has been available in the limited API [13] for some platforms (e.g. Linux), CPython makes an effort to provide the new TSS API at that level likewise. Note, however, that the Py_tss_t definition becomes to be an opaque struct when Py_LIMITED_API is defined, because exposing NATIVE_TSS_KEY_T as part of the limited API would prevent us from switching native thread implementation without rebuilding extens...
...definition of terms used in this PEP) are class objects (see also [1]). There are three main ways how the performance can be improved with the help of the proposed special methods: Creation of generic classes is slow since the GenericMeta.__new__ is very slow; we will not need it anymore. Very long method resolution orders (MROs) for generic classes will be half as long; they are present because we duplicate the collections.abc inheritance chain in typing. Instantiation of generic classes will ...
...definition. Once you have the module, call PyModule_GetState to get the state: PyObject *module = PyType_GetModuleByDef(Py_TYPE(self), &module_def); my_struct *state = (my_struct*)PyModule_GetState(module); if (state === NULL) { return NULL; } PyType_GetModuleByDef works by searching the MRO (i.e. all superclasses) for the first superclass that has a corresponding module. Note In very exotic cases (inheritance chains spanning multiple modules created from the same definition), PyType_...