What is tp_init_pointer in cpython? (original) (raw)

April 4, 2026, 2:06pm 1

I have a doubt regarding the tp_init pointer in the struct PyTypeObject.
Does it point to the user defined _ init_ or some other ??

JamesParrott (James Parrott) April 4, 2026, 2:15pm 2

jeff5 (Jeff Allen) April 4, 2026, 4:16pm 3

Yes, it points to the C implementation of __init__. Of course, it bears a slightly complex relationship to tp_new and type.__call__, but that is just the data model.

Now if the type is defined in Python, with an __init__ in Python, then this slot is made to contain a pointer to a wrapper function (in C) that dispatches to that Python method.

ganeshverse2005 (Ganesh Subramanian G.S) April 4, 2026, 5:16pm 4

thankyou….was looking for this…

ganeshverse2005 (Ganesh Subramanian G.S) April 4, 2026, 5:17pm 5

thankyou!! This made the picture clearer!!