diff options
author | Mark Shannon <mark@hotpy.org> | 2024-08-21 14:52:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-21 14:52:04 (GMT) |
commit | a4fd7aa4a6420cef1c22ec64eab54d8aea41cc57 (patch) | |
tree | 026af8576d2d3e05b56c475574606f13f69cf040 /Objects | |
parent | 4b7c4880a0b264373e65235701bb78cbf19266b5 (diff) | |
download | cpython-a4fd7aa4a6420cef1c22ec64eab54d8aea41cc57.zip cpython-a4fd7aa4a6420cef1c22ec64eab54d8aea41cc57.tar.gz cpython-a4fd7aa4a6420cef1c22ec64eab54d8aea41cc57.tar.bz2 |
GH-115776: Allow any fixed sized object to have inline values (GH-123192)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/object_layout.md | 4 | ||||
-rw-r--r-- | Objects/typeobject.c | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/Objects/object_layout.md b/Objects/object_layout.md index 3524094..4a78166 100644 --- a/Objects/object_layout.md +++ b/Objects/object_layout.md @@ -28,6 +28,10 @@ So the pre-header is these two fields: If the object has no physical dictionary, then the ``dict_pointer`` is set to `NULL`. +In 3.13 only objects with no additional data could have inline values. +That is, instances of classes with `tp_basicsize == sizeof(PyObject)`. +In 3.14, any object whose class has `tp_itemsize == 0` can have inline values. +In both versions, the inline values starts `tp_basicsize` bytes after the object. <details> <summary> 3.12 </summary> diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 0d7009a..f74d5122 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -8340,7 +8340,7 @@ type_ready_managed_dict(PyTypeObject *type) return -1; } } - if (type->tp_itemsize == 0 && type->tp_basicsize == sizeof(PyObject)) { + if (type->tp_itemsize == 0) { type->tp_flags |= Py_TPFLAGS_INLINE_VALUES; } return 0; |