mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
GH-91095: Specialize calls to normal Python classes. (GH-99331)
This commit is contained in:
parent
c01da2896a
commit
04492cbc9a
20 changed files with 511 additions and 189 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue