Skip to main content

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

Project description

(8 minutes)

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

Getting started (2 minutes)

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 will exist 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]

Also there is cookbook.

  • Pythonium Compliant 100% compliant with CPython 3

Why? (3 minutes)

Is 100% compliance of any interest right now? Do you need to build anything that uses all the features of CPython right now? No.

Can you trade some features for speed? Yes.

For the industry, experienced programmers, and hobbyists, the best approach is to have something tailored to get things done in the browser with the syntax they prefer.

As things stand, APIs differ significantly between back-end and front-end environments, so there will always be differences. For instance, if you choose pythonium core you will need to learn to work with Javascript arrays and objects and work around their specificities. Working around specifities of the language can be boring, but it’s the best that is available right now, and it’s after all, not that bad.

As a programmer that knows both Python and Javascript, I prefer to focus on what is the easiest for me to do and maximise what I will be able to do next. The immediate answer to this answer is what is already available in the repository.

How? (1 minute)



Documentation is available in the wiki.


LGPL 2.1 or later

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

Project details

Release history Release notifications

History Node


History Node


History Node


History Node


History Node


History Node


History Node


This version
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.4.5.tar.gz (13.0 kB) Copy SHA256 hash SHA256 Source None Dec 2, 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