2

Okay, so I am learning Python and I have to say it's a very interesting language but I have some questions about how the language is built under the hood as the documentation I can find by Guido doesn't give away all the secrets.

So for the question I am referencing this documentation:
https://python.org/download/...__

So, what does __new__ actually look like inside? Is there a way to see how python itself implements __new__?

I know that the mechanism for C++ malloc and new are well known definitions within that space, but I am having issues understanding exactly what the default __new__ is doing on the machine level.

The documentation I found is great for explaining how to use and override __new__ but it doesn't show what python does it once you hand off operations back to the system.

Any help is greatly appreciated!

Comments
  • 2
    Python is open source, so if you know a little a bit of C, you can try looking into it
  • 0
    You can find it here somewhere https://github.com/python/cpython/...__
  • 0
    When it comes to creating classes, have a look at `type`. not only tells the type of an object, but also creates new classes. you could read up on metaclasses to learn how to inject yourself into that procedure.
Add Comment