diff options
Diffstat (limited to 'Include/cpython/object.h')
| -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 */ |
