Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Doc/c-api/typeobj.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ Quick Reference
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
| :c:member:`~PyTypeObject.tp_vectorcall` | :c:type:`vectorcallfunc` | | | | | |
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
| :c:member:`~PyTypeObject.tp_obj_offset` | const Py_ssize_t | | | X | ~ | |
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+

.. [#slots]
A slot name in parentheses indicates it is (effectively) deprecated.
Expand Down Expand Up @@ -1015,6 +1017,12 @@ and :c:type:`PyType_Type` effectively act as defaults.)
:c:func:`PyType_HasFeature` takes a type and a flags value, *tp* and *f*, and
checks whether ``tp->tp_flags & f`` is non-zero.

.. data:: Py_TPFLAGS_USES_OPAQUE_OBJECT

This bit is set when the type object's :c:member:`PyTypeObject.tp_basicsize` is configured
for an opaque :c:type:`PyObject` structure. The value of :c:member:`PyTypeObject.tp_basicsize` is the size of the type's
internal object structure EXCLUDING the base type's structure size.

.. data:: Py_TPFLAGS_HEAPTYPE

This bit is set when the type object itself is allocated on the heap, for
Expand Down
2 changes: 2 additions & 0 deletions Include/cpython/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ struct _typeobject {

destructor tp_finalize;
vectorcallfunc tp_vectorcall;
/* INTERNAL USE ONLY! MODIFYING THIS CAN CRASH PYTHON! */
const Py_ssize_t tp_obj_offset;
};

/* The *real* layout of a type object when allocated on the heap */
Expand Down
3 changes: 3 additions & 0 deletions Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ Code can use PyType_HasFeature(type_ob, flag_value) to test whether the
given type object has a specified feature.
*/

/* Set if the type object's tp_basicsize is set for opague object */
#define Py_TPFLAGS_OPAQUE_OBJECT (1UL << 8)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer a more explicit name, lilke: Py_TPFLAGS_OMIT_PYOBJECT_SIZE.


/* Set if the type object is dynamically allocated */
#define Py_TPFLAGS_HEAPTYPE (1UL << 9)

Expand Down