diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2023-03-29 22:53:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-29 22:53:30 (GMT) |
commit | 121057aa3600c4d4d392539aeb79e1b09fd5659d (patch) | |
tree | ed1b99c697ad052eb38e38c2da2d07bfe2bf0838 /Include/cpython | |
parent | e647dbaded898e5399d01d06771c1b42b5631be8 (diff) | |
download | cpython-121057aa3600c4d4d392539aeb79e1b09fd5659d.zip cpython-121057aa3600c4d4d392539aeb79e1b09fd5659d.tar.gz cpython-121057aa3600c4d4d392539aeb79e1b09fd5659d.tar.bz2 |
GH-89987: Shrink the BINARY_SUBSCR caches (GH-103022)
Diffstat (limited to 'Include/cpython')
-rw-r--r-- | Include/cpython/object.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Include/cpython/object.h b/Include/cpython/object.h index 859ffb9..98cc51c 100644 --- a/Include/cpython/object.h +++ b/Include/cpython/object.h @@ -234,7 +234,18 @@ struct _typeobject { * It should should be treated as an opaque blob * by code other than the specializer and interpreter. */ struct _specialization_cache { + // In order to avoid bloating the bytecode with lots of inline caches, the + // members of this structure have a somewhat unique contract. They are set + // by the specialization machinery, and are invalidated by PyType_Modified. + // The rules for using them are as follows: + // - If getitem is non-NULL, then it is the same Python function that + // PyType_Lookup(cls, "__getitem__") would return. + // - If getitem is NULL, then getitem_version is meaningless. + // - If getitem->func_version == getitem_version, then getitem can be called + // with two positional arguments and no keyword arguments, and has neither + // *args nor **kwargs (as required by BINARY_SUBSCR_GETITEM): PyObject *getitem; + uint32_t getitem_version; }; /* The *real* layout of a type object when allocated on the heap */ |