[Python-Dev] When does `PyType_Type.tp_alloc get assigned to PyType_GenericAlloc ? (original) (raw)
Randy Eels randyeels at gmail.com
Sun Feb 7 08:58:55 EST 2016
- Previous message (by thread): [Python-Dev] Google Summer of Code
- Next message (by thread): [Python-Dev] When does `PyType_Type.tp_alloc get assigned to PyType_GenericAlloc ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi everyone,
I've a question about the implementation of the type
builtin (in Python
3.5).
In Objects/typeobject.c, the tp_alloc
slot of PyType_Type gets set to 0.
However, I can see (using gdb) that it later gets assigned to
&PyType_GenericAlloc
. I'd argue that this makes sense because, in
type_new
, 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->tp_alloc(metatype, nslots);
Yet, I can't seem to understand where and when does the tp_alloc
slot of
PyType_Type get re-assigned to PyType_GenericAlloc. Does that even happen?
Or am I missing something bigger?
And, just out of further curiosity, why doesn't the aforementioned slot get
initialised to PyType_GenericAlloc
in the first place?
Thanks a lot. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20160207/c26895a9/attachment-0001.html>
- Previous message (by thread): [Python-Dev] Google Summer of Code
- Next message (by thread): [Python-Dev] When does `PyType_Type.tp_alloc get assigned to PyType_GenericAlloc ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]