Various Implementations of Python

Most often whenever word Python is used its referred to CPython implementation, but there does exist other implementations of python.

Different Python Implementations

ImplementationDescription
CPythonUnderlining code is in C programming language
JythonImplementation of the Python programming language designed to run on the Java platform
IronPythonPython implemented to interact with .Net Framework
StacklessUnique implementation of Python in C Programming language without depending upon C call stack
PyPyIts also implemented in C programming languages like CPython but its a just-in-time compiler not an interpreter like CPython

Primary reason for having these different implementations of Python is to make it compatible to run on different platforms efficiently. For example – IronPython can be easily integrated to other .Net Framework based applications.

CPython Standard Implementation of Python

It’s most commonly used implementation of Python, if you have setup Python on your laptop/PC for general use then it may be CPython implementation. You can see its source code on github – CPython Source Code.
I just want to give you a brief overview of file structure of source code here and If you want to know exactly How does CPython works? See Workings of Python Interpreter.

File structure of CPython Implementation

  • Doc – Contain official documentation of CPython
  • Grammer – Contains EBNF grammer file for Python
  • Lib – Part of CPython implemented purely in Python
  • Mac – Contains some functionality specific to Mac OS
  • Misc – Developer Specific Documentation
  • Modules – Contains code purely implemented in Pytho
  • Objects – Code for built-in types
  • PC – Code specifically for Windows Operating Systems
  • PCbuild – Build files for the version of MSVC currently used for the Windows installers provided on python.org
  • Parser – Contains code for AST(Abstract Syntax Tree) nodes
  • Programs – C executables files source code and main function for CPython interpreter
  • Python – Contains code files which make core CPython runtime including compiler, eval loop and different Python built in modules.
  • Tools – Different tools for maintaining Python Programming Languages

Python for Java Implementation – Jython

Jython makes integration of Python with Java Programming Language possible, fundamentally Jython contains Java Classes which compile Python code to Java Byte Code which then is executed by Java Virtual Machine(JVM).
Jython scripts are mostly used by Java Developers as a scripting language for building web applets, servlets and GUI interfaces.
Jython Official DocumentationJython

IronPython – Python for .Net Framework

Iron Python allows Python programmers to specifically work with .Net Framework developed by Microsoft. IronPython kind of provides a window for Python developers to gain access to different languages in .Net Frameword(Prominent being C#) and other .Net technologies.
Due to this additional functional capabilities IronPython can be used either on client side or side in .Net Frameword based applications.
IronPython Official DocumentationIronPython

Stackless Python Implementation

Stackless Python is somewhat modified version of CPython focussing primarily on improving internal processes like Concurrency. Unlike CPyton, Stackless don’t have any save state on C language call stack and instead uses microthreads which makes it more efficient for multitasking(processing multiple threads at same time). Owing to this Stackless is faster than CPython.
Stackless Official DocumentationStackless

PyPy Python Implementation

PyPy is kind of similar to CPython but its optimised specifically for performance. For achieving higher performance PyPy uses JIT(just-in-time) compiler and also allows integration of Stackless python’s microthreads in it. Which further boosts up performance of PyPy.
Other implementations of Python like CPython firstly compile python code to byte code and then execute it using virtual machine but PyPy do compilation and execution both at same time(Dynamically executing code). Because of this simultaneous process of compiling and executing PyPy is faster than other python implementations.
PyPy Official DocumentationPyPy

Conclusion

Whenever I talk about different python’s implementations at some conference or some other events. First question people ask Why to use PyPy rather than CPython? or some similar question like this. The answer is clear “It depends” what’s tradeoffs are for what you want to build. Do you need to have faster execution or do you need to interact with some .Net based front end.
Consider what’s each of Python’s Implementation is made for and then make a decision which one to go for.

Also I’ve put together a lot more content about Python Programming language here on this website. If in case your interested and want to have a look see – Computer Science Hub Python Programming language.

Josh

Hi, I'm Josh a Computer Science graduate from California State University, Sacramento since coming out with my Master's from university. I've worked with multiple startups across US and in UK as well primarily as a Python Developer. Here on this website, I'm sharing my knowledge of Python. If you want to ask me anything about Python feel free to reach out, I would be happy to help you out.

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts