Skip to main content

Make your Python code fly at transonic speeds!

Latest version Code coverage Documentation status Supported Python versions Heptapod CI Github Actions Linux Github Actions Windows mybinder sonarcloud

Documentation: https://transonic.readthedocs.io

Transonic is a pure Python package (requiring Python >= 3.11) to easily accelerate modern Python-Numpy code with different accelerators (currently Cython, Pythran, Numba and JAX, but potentially later Cupy, PyTorch, Weld, Pyccel, etc...).

The accelerators are not hard dependencies of Transonic: Python codes using Transonic run fine without any accelerators installed (of course without speedup)!

The long-term project

Transonic targets Python end-users and library developers.

It is based on the following principles:

  • We'd like to write scientific / computing applications / libraries with pythonic, readable, modern code (Python >= 3.6).

  • In some cases, Python-Numpy is too slow. However, there are tools to accelerate such Python-Numpy code which lead to very good performances!

  • Let's try to write universal code which express what we want to compute and not the special hacks we want to use to make it fast. We just need nice ways to express that a function, a method or a block of code has to be accelerated (and how it has to be accelerated). We'd like to be able to do this in a pythonic way, with decorators and context managers.

  • There are many tools to accelerate Python-Numpy code! Let's avoid writting code specialized for only one of these tools.

  • Let's try to keep the code as it would be written without acceleration. For example, with Transonic, we are able to accelerate (simple) methods of classes even though some accelerators don't support classes.

  • Let's accelerate/compile only what needs to be accelerated, i.e. only the bottlenecks. Python and its interpreters are good for the rest. In most cases, the benefice of writting big compiled extensions (with Cython or in other languages) is negligible.

  • Adding types is sometimes necessary. In modern Python, we have nice syntaxes for type annotations! Let's use them.

  • Ahead-of-time (AOT) and just-in-time (JIT) compilation modes are both useful. We'd like to have a nice, simple and unified API for these two modes.

    • AOT is useful to be able to distribute compiled packages and in some cases, more optimizations can be applied.
    • JIT is simpler to use (no need for type annotations) and optimizations can be more hardware specific.

    Note that with Transonic, AOT compilers (Pythran and Cython) can be used as JIT compilers (with a cache mechanism).

To summarize, a strategy to quickly develop a very efficient scientific application/library with Python could be:

  1. Use modern Python coding, standard Numpy/Scipy for the computations and all the cool libraries you want.
  2. Profile your applications on real cases, detect the bottlenecks and apply standard optimizations with Numpy.
  3. Add few lines of Transonic to compile the hot spots.

What we have now

We start to have a good API to accelerate Python-Numpy code (functions, methods and blocks of code). The default Transonic backend uses Pythran and works well. Here, we explain why Pythran is so great for Python users and why Transonic is great for Pythran users. There are also (more experimental) backends for Cython and Numba.

Installation and configuration

pip install transonic

Transonic is sensible to environment variables:

  • TRANSONIC_DIR can be set to control where the cached files are saved.
  • TRANSONIC_DEBUG triggers a verbose mode.
  • TRANSONIC_COMPILE_AT_IMPORT can be set to enable a mode for which Transonic compiles at import time the Pythran file associated with the imported module. This behavior can also be triggered programmatically by using the function set_compile_at_import.
  • TRANSONIC_NO_REPLACE can be set to disable all code replacements. This is useful to compare execution times and when measuring code coverage.
  • TRANSONIC_COMPILE_JIT can be set to false to disable the compilation of jited functions. This can be useful for unittests.
  • TRANSONIC_BACKEND to choose between the supported backends. The default backend "pythran" is quite robust. There are now 3 other backends: "cython", "numba" and "python" (prototypes).
  • TRANSONIC_MPI_TIMEOUT sets the MPI timeout (default to 5 s).

License

Transonic is distributed under the BSD License.

Metadata

Release files for transonic 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for transonic 0.8.1
File Size Uploaded
transonic-0.8.1.tar.gz 73.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for transonic 0.8.1
File Interpreter ABI Platform
transonic-0.8.1-py3-none-any.whl Python 3 none any Details

Total release size: 150.6 kB

Release files / transonic-0.8.1.tar.gz

Download URL transonic-0.8.1.tar.gz
Size 73.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dcd4e1a9ad14baa6f910da5bfc382d784d8b70652be952d3f4232ad98bd53c52
BLAKE2b-256 checksum
How to use checksums
7915257ab548ef44ff1a521c32e68d658938e9757e5ada44907dbc253594b419
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.29.2 CPython/3.12.15 Linux/7.2.9-clevercloud-vm-dirty

Release files / transonic-0.8.1-py3-none-any.whl

Download URL transonic-0.8.1-py3-none-any.whl
Size 77.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e647577ea89b40e07b6ba4bb11c07347d1c419a91e54a1d23d6ca66b63f4862d
BLAKE2b-256 checksum
How to use checksums
c1c0791949013250756de76b39b1cc4b175273e961a037613cc229ad49dbb37b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.29.2 CPython/3.12.15 Linux/7.2.9-clevercloud-vm-dirty

Release history Release notifications | RSS feed

This release

0.8.1 This release

2 release files

0.8.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.12

2 release files

0.4.10

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.11

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page