Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean when people say CPython is written in C?

Tags:

python

cpython

From what I know, CPython programs are compiled into intermediate bytecode, which is executed by the virtual machine. Then how does one identify without knowing beforehand that CPython is written in C. Isn't there some common DNA for both which can be matched to identify this?

like image 599
Anish Shah Avatar asked Nov 28 '22 04:11

Anish Shah


1 Answers

The interpreter is written in C.

It compiles Python code into bytecode, and then an evaluation loop interprets that bytecode to run your code.

You identify what Python is written in by looking at it's source code. See the source for the evaluation loop for example.

Note that the Python.org implementation is but one Python implementation. We call it CPython, because it is implemented in C. There are other implementations too, written in other languages. Jython is written in Java, IronPython in C#, and then there is PyPy, which is written in a (subset of) Python, and runs many tasks faster than CPython.

like image 142
Martijn Pieters Avatar answered Nov 29 '22 17:11

Martijn Pieters