Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Location of `object.__init__`

Where is object.__init__ located in the cpython repository?
I searched for __init__ in Objects/object.c, but it gives no results.

It appears that all the immutable data types use object.__init__, so I would like to know the implementation of it.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Objects/object.c is where (most of) the object protocol is implemented, not where object is implemented.

object is implemented along with type in Objects/typeobject.c, and its __init__ method is object_init in that file.

(Note that the very similar-sounding PyObject_Init function is actually completely unrelated to object.__init__. PyObject_Init is a generic helper function that performs type pointer and refcount initialization for a newly-allocated object struct.)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading