PYTHON IMPLEMENTATIONS - Complete Guide For Python Programming (2015)

Complete Guide For Python Programming (2015)

PYTHON IMPLEMENTATIONS

An "implementation" of Python provides support for the execution of programs which are written in the Python Programming language, is represented by the CPython reference implementation. There several implementation to run python programs. Let’s have a look at them:

CPython Variants

These are implementations which are based on the CPython runtime core, but with extended behavior or features in some aspects.

CrossTwine Linker - A combination of CPython and an add-on library offering improved performance.

Stackless Python - CPython with an emphasis on concurrency using tasklets and channels.

Unladen-Swallow - an optimization branch of CPython, intended to be fully compatible and significantly faster.

WPython - a re-implementation of CPython using "wordcode" instead of bytecode.

Other Implementations

These are re-implementations of the Python language that do not depend on the CPython runtime core. Many of them reuse the standard library implementation. The only implementations that are known to be compatible with a given version of the language are IronPython, Jython and PyPy.

The following implementations are comprehensive or even complete, that you can run typical programs with them already:

Brython - A way to run Python in the browser through translation to JavaScript.

CLPython - Python in Common Lisp.

HotPy - A virtual machine for Python supporting bytecode optimization and translation using type information gathered at run-time.

IronPython - Python in C# for the Common Language Runtime (CLR/.NET) and the FePy project's IronPython Community Edition (IPCE).

Jython - Python in Java for the Java platform.

Pyjs - A Python to JavaScript compiler plus Web/GUI framework.

PyMite - Python for embedded devices.

PyPy - Python in Python, targeting several environments.

Pyvm - A Python-related virtual machine and software suite providing a nearly self-contained "userspace" system.

RapydScript - A Python-like language that compiles to JavaScript.

SNAPpy - A subset of the Python language that has been optimized for use in low-power embedded devices.

Tinypy - A minimalist implementation of Python in 64K of code .

Tentative Implementations

The following implementations are apparent works in progress; they may not be able to run typical programs:

Berp - an implementation of Python 3 in Haskell, providing an interactive environment as well as a compiler.

Phpython - a Python interpreter written in PHP.

Pyjaco - a Python to JavaScript compiler similar to Pyjs but lighter weight.

Pystacho - is, like Skulpt, Python in JavaScript.

Pyvm2.py - a CPython bytecode interpreter written in Python.

Skulpt - Python in JavaScript.

Typhon - a Rubinius-based implementation of Python.

Python Compilers & Numerical Accelerators

Compilers

These compilers usually implement something close to Python, have a look at them:

2c-python - a static Python-to-C compiler, apparently translating CPython bytecode to C.

Compyler - an attempt to "transliterate the bytecode into x 86 assemblies".

Cython - a widely used optimizing Python-to-C compiler, CPython extension module generator, and wrapper language for binding external libraries. Interacts with CPython runtime and supports embedding CPython in stand-alone binaries.

GCC Python Front-End - an in-progress effort to compile Python code within the GCC infrastructure.

Nuitka - a Python-to-C++ compiler using libpython at run-time, attempting some compile-time and run-time optimizations. Interacts with CPython runtime.

Pyc - performs static analysis in order to compile Python programs, uses similar techniques to Shed Skin.

Shed Skin - a Python-to-C++ compiler, restricted to an implicitly statically typed subset of the language for which it can automatically infer efficient types through whole program analysis.

UnPython - a Python to C compiler using type annotations.

Numerical Accelerators

Copperhead - purely functional data-parallel Python compiles to multi-core and GPU backends.

Numba - NumPy-aware optimizing runtime compiler for Python.

Parakeet - runtime compiler for a numerical subset of Python.

Logical And Physical Line in Python

A physical line is what you see when you write the program in python. A logical line is what Python sees as a single statement. Python implicitly assumes that each physical line corresponds to a logical line. For example, you want to write - 'hello world' - if this was on a line by itself, then this also corresponds to a physical line.

If you want to specify more than one logical line on a single physical line, then you have to explicitly specify this using a semicolon (;) which indicates the end of a logical line/statement.

For example:

i = 12

print i

is effectively same as

i = 12;

print i;

which is also same as

i = 12; print i;

and same as

i = 12; print i

If you have a long line of code, you can break it into multiple physical lines by using the backslash. This is referred to as explicit line joining:

s = 'This is a python book. \

This continues the book.'

print s

Output:

This is a python book. This continues the book.

Similarly,

print \

i

is the same as

print i

Sometimes, there is an implicit assumption where you don’t need to use a backslash. This is the case where the logical line has starting parentheses, starting square brackets or a starting curly braces but not an ending one. This is called implicit line joining. You can see this in action when we write programs using lists in later chapters.