Python Implementations - Implementations

Implementations

See also: List of Python software#Python implementations

The main Python implementation, named CPython, is written in C meeting the C89 standard. It compiles Python programs into intermediate bytecode, which is executed by the virtual machine. CPython is distributed with a large standard library written in a mixture of C and Python. It is available in versions for many platforms, including Microsoft Windows and most modern Unix-like systems. CPython was intended from almost its very conception to be cross-platform.

PyPy is a fast, compliant interpreter of Python 2.7. Its just-in-time compiler brings a significant speed improvement over CPython. A version taking advantage of multi-core processors using software transactional memory is in the works.

Stackless Python is a significant fork of CPython that implements microthreads; it does not use the C memory stack, thus allowing massively concurrent programs. PyPy also has a stackless version.

Other just-in-time compilers have been developed in the past, but are now unsupported:

  • Google started a project called Unladen Swallow in 2009 with the aims of increasing the speed of the Python interpreter by 5 times by using the LLVM and improving its multithreading ability to scale to thousands of cores. Later the project lost Google's backing and its main developers. As of 1 February 2012 (2012-02-01), the modified interpreter was about 2 times faster than CPython.
  • Psyco is a specialising just in time compiler that integrates with CPython and transforms bytecode to machine code at runtime. The produced code is specialised for certain data types and is faster than standard Python code.

In 2005 Nokia released a Python interpreter for the Series 60 mobile phones called PyS60. It includes many of the modules from the CPython implementations and some additional modules for integration with the Symbian operating system. This project has been kept up to date to run on all variants of the S60 platform and there are several third party modules available. The Nokia N900 also supports Python with GTK widget libraries, with the feature that programs can be both written and run on the device itself.

There are several compilers to high-level object languages, with either unrestricted Python, a restricted subset of Python, or a language similar to Python as the source language:

  • Jython compiles into Java byte code, which can then be executed by every Java Virtual Machine implementation. This also enables the use of Java class library functions from the Python program.
  • IronPython follows a similar approach in order to run Python programs on the .NET Common Language Runtime.
  • The RPython language can be compiled to C, Java bytecode or Common Intermediate Language, and is used to build the PyPy interpreter of Python;
  • Pyjamas compiles Python to JavaScript;
  • Shed Skin compiles Python to C++;
  • Cython and Pyrex compile to C.

Read more about this topic:  Python Implementations