Wandering Thoughts archives


The difference between CPython and Python

Sometimes when I'm writing about Python things, I talk about 'CPython' (as I did yesterday). This is insider jargon; CPython is the term of art that's generally used when we're specifically referring to the behavior of the main implementation of Python (which is written in C, hence the 'CPython' coinage). This is the implementation that gets most of the publicity and a starring role on python.org. CPython is the Python that is 'version 2.7.6' and 'version 3.3.3' (as of right now) and is what the core Python developers work on. But it's not the only implementation of Python that exists. Today the most prominent other implementation of Python is probably PyPy; other implementations include Jython (Python in the JVM) and IronPython (Python in the CLR).

CPython is the original version of Python and for a long time it was the only Python that existed. It's still the authoritative version that everyone else is expected to be compatible with, because there is no comprehensive language specification for 'Python the language'. This is pretty common with all sorts of languages these days, which are generally implemented first and standardized later if at all.

(Among other reasons for this, writing a comprehensive language specification is a lot of work and then it is even more work to keep updating it as you change the language. And you don't really know if your specification was comprehensive enough until some crazy person attempts a second implementation purely from the specification without looking at how your language implementation behaves. If their implementation is fully compatible, your specification was a good one.)

I (and others) talk about CPython when we're talking about things that are specific to how CPython is implemented, that are specifically documented as implementation dependent, or that are simply likely to be implementation dependent rather than slavishly copied by everyone who does a Python implementation. For obvious reasons, pretty much all of the low level details of how CPython works fall into this general category, eg other Python implementations are unlikely to copy CPython's bytecode architecture. Where the boundary is between low level behavior and high level behavior is an interesting and sometimes debatable question (as is what is likely to wind up being implementation dependent).

(Note that all Python implementations have the 'Python 2 vs Python 3' issue, because the changes between Python 2 and Python 3 are general language changes.)

python/CPythonVsPython written at 01:59:43; Add Comment

Page tools: See As Normal.
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.