Skip to main content

Python 3 to Javascript translator written in Python that produce fast portable javascript code

Project description

tldr: Python 3 to Javascript translator written in Python that produces fast portable javascript code.

Read the tutorial.

(8 minutes)

Quick examples (2 minutes)

Hello, World!:

$ echo "print('Hello, world')" >>
$ pythonium -V
console.log("Hello, world");

A loop.

$ echo "for i in range(10): print(i)" >>
$ pythonium -V
var iterator_i = range(10);
for (var i_iterator_index=0; i_iterator_index < iterator_i.length; i_iterator_index++) {
    var i = iterator_i[i_iterator_index];

Getting started (2 minutes)

You can try Pythonium in the online web console

You will need Python 3 to run the translator. Refer to your operating system documentation to know how to do it (most Linux distributions have Python 3 readily available).

Then you can use pip to install the stable translator:

pip install pythonium

The above package installs a pythonium command that has the following options:



pythonium [-h][-d][-r][-V][FILE ...] [-o FILE]|[-g]


-h --help        show this
-v --version     show version
-o --output FILE specify output file [default: stdout]
-d --deep        generate file dependencies. If --output is not provided, it will generate for each source file a coresponding .js file.
-r --requirejs   generate requirejs compatible module
-V --veloce      use veloce mode, Python syntax with JavaScript semantic
-g --generate    generate pythonium library

What? (2 minutes)

Pythonium exists in two flavors, each with their own strengths and performance characteristics. As you go down the list the more features you’ll have, and performance will, of course, decrease with sophistication (but not much):

  • Pythonium Veloce
    • Fully portable
    • Native Javascript speed
    • Exact same syntax as Python 3
    • Compatible with existing Javascript libraries
    • Functions are translated to Javascript functions with support for keyword arguments, *args and **kwargs
    • Automatic scope handling and global support
    • for iterates over Javascript arrays
    • Python types are mapped to Javascript types
    • Anonymous exceptions with __exception__ special variable
    • Support of yield
    • print is translated to console.log
    • new(SomeObject, arg0, arg1) as a special function that translates to Javascript new SomeObject(arg0, args1) with any number of arguments
    • if __DOLLAR__ is found in any name, it will be replaced by $ character.
    • Support of from ... import ... via requirejs
    • Support of single inheritance classes via classy [1][2]

[1] Nested class definition are not supported [2] Calling super method is done with super(arg0, arg1, arg2, ...)

  • Pythonium Compliant All the above and 100% compliant with CPython 3

How? (1 minute)



LGPL 2.1 or later

Bitdeli badge

Project details

Release history Release notifications

History Node


This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
pythonium-0.6.2.tar.gz (21.7 kB) Copy SHA256 hash SHA256 Source None Dec 28, 2013

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page