Python runtimes — pythoncapi 0.1 documentation (original) (raw)

To be able to implement backward compatibility, the plan is to provide multiple Python runtimes, at least two. An “old” runtime with maximum backward compatibility, and one “new” runtime which includes experimental new changes but requires using the newer C API.

Welcome into the bright world of multiple new cool and compatible Python runtimes!

Regular Python: /usr/bin/python3

Compared to Python 3.7 regular runtime, this runtime no longer check its arguments for performance reasons. The debug runtime should now be preferred to develop C extensions and to run tests.

Example of Python 3.7 code:

int PyList_Append(PyObject *op, PyObject *newitem) { if (PyList_Check(op) && (newitem != NULL)) return app1((PyListObject *)op, newitem); PyErr_BadInternalCall(); return -1; }

The if (PyList_Check(op) && (newitem != NULL)) belongs to the debug runtime and should be removed from the regular Python.

Debug runtime: /usr/bin/python3-dbg

For example, the debug runtime can check that the GIL is held by the caller.

See also

New experimental runtime: python3-exp

Technically, this experimental runtime can be a opt-in compilation mode of the upstream CPython code base.

See Optimization ideas.

Other Python implementations

Last 10 years, CPython has been forked multiple times to attempt different CPython enhancements:

Sadly, none is this project has been merged back into CPython. Unladen Swallow lost its funding from Google, Pyston lost its funding from Dropbox, Pyjion is developed in the limited spare time of two Microsoft employees.

Other Python implementations written from scratch:

Since the C API will be smaller and the stable ABI will become more usable, you can imagine that Python implementations other than CPython will be able to more easily have a full and up-to-date support of the latest full C API.

Put your CPython fork here¶

Since a stable ABI have been designed, if all your C extensions have opt-in for the new C API: you are now allowed to fork CPython and experiment your own flavor CPython. Do whatever you want: C extensions only calls your runtime through function calls.

See Optimization ideas.