Skip to main content

Python to JavaScript transpiler, supporting multiple inheritance and generating lean, highly readable code

Project description


Python in the browser, precompiled for speed:

  • Precompiled into highly readable, efficient JavaScript, downloads kB’s rather than MB’s

  • Multiple inheritance, optional operator overloading, metaclasses, properties, class and function decorators, hierarchical modules etc.

  • Seamless integration with the universe of high-quality web-oriented JavaScript libraries, rather than the desktop-oriented Python ones

  • Pure Python 3.5 syntax, using Python’s native parser

  • Debug directly from Python sourcecode, through integrated sourcemaps

  • Generates JavaScript for humans, resembling the Python source line by line, optionally annotated with source line numbers

  • Lightning fast JavaScript 5 and 6 code: call caching, for-loop optimization, in-line JavaScript etc.

  • Integrated static typechecking and minification at the tip of a command line switch

  • Also runs on top of node.js

  • Extensive documentation with many code examples

  • Apache 2.0 license

  • Pip-install and go!

Latest stable release: Athens

To obtain the latest stable release including all updates, install it from PyPi as described in the documentation.

Thanks to everyone who contributed!


As can be seen below, there’s a simple parallel between the Python and the JavaScript code. So it should be easy to debug. Also, code can be tested from the command prompt using stubs.

Screenshot of Python versus JavaScript code

Classic OO with multiple inheritance in JavaScript

Main differences with CPython

  • Web batteries: Seamless access to any existing JavaScript library has been favored over inclusion of many Python libraries in the distribution. There are some exceptions to this rule, e.g. like math, cmath, random, itertools, time and turtle, and some more may follow, but in general the accent is on libraries that are relevant in the browser.

  • A few methods of builtin types are currently left out, especially when they (almost) duplicate functionality of other methods. Also method decorators (as opposed to function decorators and class decorators) are not supported, with the exception of @classmethod. This results from a deliberate choice to keep Transcrypt lean and fast.

  • No eval and exec of Python code. This is again part of the concept. Transcrypt code is compiled, optimized and minified in advance to warant fast page loads. In this respect its design goal is fundamentally different from tools that compile on the fly in the browser. Transcrypt is targeted towards building professional, extensive, real world web applications that load and run as fast as their JavaScript counterparts, but offers Pythonically clean, modular structure and maintainability.

Information for contributors

How to contribute

Transcrypt started out as a personal repo, owned by Jacques de Hooge. As the project caught on and the number of people contributing issues, ideas and code grew, the repo was transferred to the QQuick organisation, to be able to form a developer team on GitHub.

There was also a clear message in this: Transcrypt isn’t owned by anyone in particular. It is the collective property of everyone using it or contributing to it. At the same time the need was felt to keep a very firm grip on code quality, especially of the core.

Everything under ../transcrypt/modules/org/transcrypt plus the file ../transcrypt/ is considered to be part of Transcrypt’s core. A major design goal is to keep the core small and fast. This means that some CPython facilities were deliberately left out or simplified. Core development is still mainly done by Jacques, but with the input of many great ideas submitted as issues. If you want to improve something in the core, this is best initiated by first opening an issue for it. Opening a pull request directly can lead to disappointment, although all effort is made to take good ideas seriously.

All other parts of Transcrypt are referred to as periphery. While a good quality pull request for the periphery stands a reasonable chance of being accepted, still it is wise to start an issue beforehand, allowing coordination and preventing waste of effort.

A special place is taken by implementing standard libraries. While Transcrypt mostly relies on browser-centric JavaScript libraries, availability of a limited number of standard libraries will help acceptance by Python programmers. So you’re most welcome to make a contribution here. The design goal again is: better 90% complete, fast, small, and reliable, than 100% complete, slow, bulky and buggy. If you contribute a library, please also contribute an autotest (see docs) and some documentation for it. The supported platforms are Windows and Linux (and, with that, OsX).

While being open and respectful to any good ideas, the final say as to what gets in and what doesn’t, is with Jacques. So this is a dictatorial rather than a democratic project. Being a sailer himself, Jacques values the notion of having one captain on a ship. The captain doesn’t own the ship, but he serves the passengers by consulting with the crew and plotting one stable course.

Another possibility to contribute libraries to Transcrypt is by submitting them as separate packages to PyPi. In that case be sure to add the keyword Transcrypt to allow people to find your package. Making your package pip-installable will also help it to catch on. Contributing packages via PyPi of course means total freedom for the developer.

Development build status

The build status icons that have become en vogue deserve some expectation management. While we’re working to improve both coverage and semantic depth of the continuous integration tests, they are still very limited compared to the shipment tests that precede a release. Also, since the branching model has been deliberately kept simple, they may be transiently broken. In that case you can use the latest passing version, as documented by Travis. Another possibility is to use the latest release as a basis. While this may mean some manual merging, it offers the advantage of working with shipment tested code.

What’s new in the latest commits

  • Initial versioin of chapter ‘Differences with CPython’ added to docs

  • Travis CI activated

  • Procedural improvement for issue #160: Sphinx _build dir should be Git ignored (since it obscures code diffs)

  • Enhancement for issue #143: ‘isinstance’ deserves more compat

  • Enhancement for issue #149: Transpile docstrings on demand

  • Fix for issue #151: Problem with __include__ and special character inside js

  • Enhancement for issue #150: The ‘in’ operator (was O (n), is now O (1))

  • Enhancement for issue #147: str function should return string primitive, not ‘new String ()’

  • Fix for issue #145: List sorting (fails due to erroneous compare operator)

  • Fix for issue #144: List comprehensions and opov (don’t go well together, missing ‘this’ pointer)

  • Fix for issue #138: Parse error using ‘yield’ in expression, ‘send’ missing (see testlet iterators_and_generators) and the discussion at the issue.

  • Fix for issue #140: commandline –help / -h switch broken

  • Enhancement for issue #128: metaclasses (only __new__ overridable) + test case / doc example

  • Enhancement for issue #136: dict.get not implemented

  • Fix for issue #134: %= operator translated incorrectly

  • Enhancement for issue #130: Add pragma to optionally handle % the JS way

  • Fix for issue #127: Can’t use key ‘keys’ in a dict

  • Enhancement issue #113: Use for … of pervasively for js6 + autotest

  • Fix for issue #125: strings not iterable (js6 only) + autotest

  • Release 12

  • Local classes now arbitrarily nestable, issue #120

  • Operator % has now Python rather than JS behaviour, issue #123 + autotest

  • Slicing bug fixed (stop beyond list end), issue #122 + autotest

Plotly demo

Plotly demo

  • Plotly.js demo added: lim (Numscrypt -> Maturity) Transcrypt + Numscrypt + Plotly = Live Science Demos in the Browser with native JS performance, all Plotly.js plot types are supported

  • __pragma__ (‘jskeys’/’nojskeys’) added make Plotly.js code match Plotly.js docs for convenience, locally voiding the need for quotes around dir keys

  • ‘Star us on GitHub’ command line option added

  • Fix for ‘unexpected indent’ when rebuilding

  • Fix for accidentally deleting current path from sys.path in some installations

  • Fix for ‘cannot import __symbols__’ bug when using -r with autotest.

  • Exception hierarchy improved, all Transcrypt runtime exceptions now derive from Exception

  • Non-standard attribute ‘stack’ added to Exception to obtain stack trace in de-facto JavaScript compatible way

  • Attempt to iterate over non-iterable now results in exception (only when using -e 6 switch) (see issue #112))

  • Iterating over TypedArrays and other non-list iterables fixed (only needed for when using -e 6 switch) (see issue #112)

  • Release 9

  • Truthyness of instances of custom classes fixed (see issue #110)

  • Source map generation bug fixed (see issue #104)

  • Optional static type validation using mypy (experimental)

  • Small doc improvements

  • Some more fixes for Numscrypt

  • Fix to enable Numscrypt development

  • *args now also can be used in calling pure javascript methods (see issue #102)

  • Pragma’s else and elif fixed for use in .py rather than .js files

Other packages you might like


Copyright 2014, 2015, 2016 Jacques de Hooge, GEATEC engineering,

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution (15.7 MB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page