Skip to content

Commit 5baa7a0

Browse files
gh-95245: Document Py_TPFLAGS_PREHEADER (GH-135861)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
1 parent be24ff0 commit 5baa7a0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Doc/c-api/typeobj.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,19 @@ and :c:data:`PyType_Type` effectively act as defaults.)
12861286
:c:member:`~PyTypeObject.tp_weaklistoffset` field is set in a superclass.
12871287

12881288

1289+
.. c:macro:: Py_TPFLAGS_PREHEADER
1290+
1291+
These bits indicate that the VM will manage some fields by storing them
1292+
before the object. Currently, this macro is equivalent to
1293+
:c:expr:`Py_TPFLAGS_MANAGED_DICT | Py_TPFLAGS_MANAGED_WEAKREF`.
1294+
1295+
This macro value relies on the implementation of the VM, so its value is not
1296+
stable and may change in a future version. Prefer using individual
1297+
flags instead.
1298+
1299+
.. versionadded:: 3.12
1300+
1301+
12891302
.. c:macro:: Py_TPFLAGS_ITEMS_AT_END
12901303
12911304
Only usable with variable-size types, i.e. ones with non-zero

Include/object.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,9 @@ given type object has a specified feature.
550550
*/
551551
#define Py_TPFLAGS_MANAGED_DICT (1 << 4)
552552

553+
/* Type has dictionary or weakref pointers that are managed by VM and has
554+
* to allocate space to store these.
555+
*/
553556
#define Py_TPFLAGS_PREHEADER (Py_TPFLAGS_MANAGED_WEAKREF | Py_TPFLAGS_MANAGED_DICT)
554557

555558
/* Set if instances of the type object are treated as sequences for pattern matching */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy