I want to know the difference between CPython and Python because I have heard Python is developed in C - then what is the use of CPython?
Asked
Active
Viewed 1.6k times
2 Answers
38
Python is a language.
CPython is the default byte-code interpreter of Python, which is written in C.
There is also other implementation of Python such as IronPython (for .NET), Jython (for Java), etc.
kennytm
- 491,404
- 99
- 1,053
- 989
-
thx !! I understand CPython is default byte-code interpreter for Python. But who takes care of converting Python to byte-code in first place ? – rahulaga-msft Nov 01 '18 at 14:40
-
@RahulAgarwal Also CPython. The *.pyc bytecode format is specific to CPython. Other implementations could use other bytecode formats. – kennytm Nov 01 '18 at 17:10
-
ohk, got it. so this means IronPython for example converts python to msil, right? – rahulaga-msft Nov 01 '18 at 23:24
-
@RahulAgarwal Yeah. – kennytm Nov 02 '18 at 12:34
-
one more last point :) This means CPython takes care of converting Python code to Byte Code and also interpret byte code to machine code ? In nut shell CPython is **Compiler** (for conversion from Python to Byte Code) and also **Python Virtual Machine** (for Byte code to Machine code) ? When Comparing same to .Net, there is C# Compiler to Convert C# to MSIL and CLR (JIT) to convert from MSIL to Machine code. – rahulaga-msft Nov 02 '18 at 14:05
-
1@RahulAgarwal Yes. You may find details about the Compiler in https://devguide.python.org/compiler/, and the bytecode interpreter is explained in https://stackoverflow.com/questions/19916729/how-exactly-is-python-bytecode-run-in-cpython. – kennytm Nov 02 '18 at 14:29
-
thanks lot, it really helped !!! – rahulaga-msft Nov 02 '18 at 14:39
-
(late to the party): in a nutshell, Cython is an application written in C. This application is a bytecode-interpreter. Am I right? – Adarsh TS Sep 16 '20 at 12:09