[Python-Dev] When does `PyType_Type.tp_alloc get assigned to PyType_GenericAlloc ? (original) (raw)
Guido van Rossum guido at python.org
Sun Feb 7 14:45:12 EST 2016
- Previous message (by thread): [Python-Dev] When does `PyType_Type.tp_alloc get assigned to PyType_GenericAlloc ?
- Next message (by thread): [Python-Dev] When does `PyType_Type.tp_alloc get assigned to PyType_GenericAlloc ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I think it's probably line 2649 in typeobject.c, in type_new():
type->tp_alloc = PyType_GenericAlloc;
On Sun, Feb 7, 2016 at 5:58 AM, Randy Eels <randyeels at gmail.com> wrote:
Hi everyone,
I've a question about the implementation of the
type
builtin (in Python 3.5). In Objects/typeobject.c, thetpalloc
slot of PyTypeType gets set to 0. However, I can see (using gdb) that it later gets assigned to&PyTypeGenericAlloc
. I'd argue that this makes sense because, intypenew
, there is a line where that member function gets called without previously checking whether that member points to something:_ _/* Allocate the type object */_ _type = (PyTypeObject *)metatype->tpalloc(metatype, nslots);_ _
Yet, I can't seem to understand where and when does thetpalloc
slot of PyTypeType get re-assigned to PyTypeGenericAlloc. Does that even happen? Or am I missing something bigger? And, just out of further curiosity, why doesn't the aforementioned slot get initialised toPyTypeGenericAlloc
in the first place? Thanks a lot.
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/guido%40python.org
-- --Guido van Rossum (python.org/~guido)
- Previous message (by thread): [Python-Dev] When does `PyType_Type.tp_alloc get assigned to PyType_GenericAlloc ?
- Next message (by thread): [Python-Dev] When does `PyType_Type.tp_alloc get assigned to PyType_GenericAlloc ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]