GH-91095: Specialize calls to normal Python classes. (GH-99331)

This commit is contained in:
Mark Shannon 2023-06-22 09:48:19 +01:00 committed by GitHub
parent c01da2896a
commit 04492cbc9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 511 additions and 189 deletions

View file

@ -1681,6 +1681,26 @@ type_call(PyTypeObject *type, PyObject *args, PyObject *kwds)
return obj;
}
PyObject *
_PyType_NewManagedObject(PyTypeObject *type)
{
assert(type->tp_flags & Py_TPFLAGS_MANAGED_DICT);
assert(_PyType_IS_GC(type));
assert(type->tp_new == PyBaseObject_Type.tp_new);
assert(type->tp_alloc == PyType_GenericAlloc);
assert(type->tp_itemsize == 0);
PyObject *obj = PyType_GenericAlloc(type, 0);
if (obj == NULL) {
return PyErr_NoMemory();
}
_PyObject_DictOrValuesPointer(obj)->dict = NULL;
if (_PyObject_InitInlineValues(obj, type)) {
Py_DECREF(obj);
return NULL;
}
return obj;
}
PyObject *
_PyType_AllocNoTrack(PyTypeObject *type, Py_ssize_t nitems)
{