logoalt Hacker News

CPython Internals Explained

180 pointsby yufizlast Tuesday at 2:07 PM43 commentsview on HN

Comments

squeedlesyesterday at 6:21 PM

Had to write a fairly substantial native extension to Python a couple years ago and one of the things I enjoyed was that the details were not easily "Googleable" because implementation results were swamped by language level results.

It took me back to the old days of source diving and accumulated knowledge that you carried around in your head.

https://www.dave.org/posts/20220806_python/

show 3 replies
elcapitanyesterday at 11:31 PM

This looks quite nice. I always wished there was something like "Ruby Under a Microscope" for Python (and other languages). It was quite instrumental for my deeper understanding of the language.

show 1 reply
mvATM99yesterday at 4:44 PM

Very interesting! Gonna look through this for sure in the next weeks

westurneryesterday at 5:51 PM

vstinner's Python docs; "Unofficial Python Development (Victor's notes) documentation" > Garbage Collector > "Implement the GC protocol in a type": https://pythondev.readthedocs.io/garbage_collector.html#impl...

Python Developer's Guide > "CPython's internals": https://devguide.python.org/internals/index.html

Python/cpython//InternalDocs/README.md > "CPython Internals Documentation": https://github.com/python/cpython/blob/main/InternalDocs/REA...

show 1 reply
tonymetyesterday at 5:08 PM

I wish they would just go back to calling it Python, since it’s the Python that everyone knows and uses. No one gets confused over Python the spec and Python the implementation. Every time I see “CPython” i have to double check we’re just talking about Python.

I guess they “CPython’ed” back when people thought Jython would take off , and it never did because Java sucks.

show 5 replies
damjonyesterday at 5:02 PM

I've been comparing various platforms and discussing them with ChatGPT—for instance, why Python's execution is slower than JavaScript's V8. It claimed this is due to mtechnical debt and the inability to change because libraries like NumPy bypass public interfaces and access data directly.

I'm wondering how much of that is true and what is just a hallucination."

Btw: JavaScript seems to have similar complexity issues.

Edit: Python has no JIT

show 6 replies