# Does Blender support other Python implementations?

I am aware that blender can use .py scripts. But sometimes these execute fairly slow, compared to compiled code. There are several other Python implementations, which support some level of JIT compilation:

IronPython:

An open-source implementation of the Python programming language which is tightly integrated with the .NET Framework.

Jython:

A Python implementation in the Java VM.

PyPy:

A fast, compliant alternative implementation of the Python language An advantage of PyPy is, Speed: thanks to its Just-in-Time (JIT) compiler, Python programs often run faster on PyPy.

Is there anyway to make use of these optimizations as far as Blender is concerned?

Short answer, None of the other implementations.

Blender isn't just using Python for scripting, it embeds the CPython interpreter using its C-API, something which other Python implimentations don't provide.

Note: PyPy has made a start on the CPython API, it may one day be usable with Blender, currently its incomplete..

In the near future - its unlikely we will have a drop-in replacement for CPython such as IronPython, PyPy, ShedSkin, Cython... etc.

## Alternatives

### Import a faster environment

numpy is the best example of this, but there are other Python modules which you can speedup your scripts and comes bundled with Blender.

### Embed a faster environment

Embed a faster environment _in_ Python. eg:

... there are probably others.

The main downside to this is your limited to primitive types (also known as POD), (eg - bytes, ints, floats, doubles) - so you end up having to convert your data into structures both environments can handle, crunch numbers, then convert back and apply to your Blender data. Depending on the task this may not be an issue, however it does limit what you can optimize.

### Write in the C extension API

For lots of users this isnt an option and involves learning how to write extensions, in C/Python-API or in something like Cython, SWIG... etc. Listing here because in some cases a small part of the script can be ported to C/C++ for a large speedup.

This method has the potential to provide an API which executes very fast, the main downside is the time it takes to write such modules and having users install them (since they're compiled C/C++).

### Call out to a faster environment

You could execute code from any other language/environment as an external process and communicate with it via pipes/sockets (or even just process files and read them back), this may be too cumbersome both from a developer perspective and the effort users have to make to setup such an environment, but it _can_ be done and in some cases its worth the effort.

Embed a faster environment -> that seems to have a lot of potential!

llvmpy might work together with py2llvm, the latter creates the LLVM IR, the former would load and execute it (not sure if it can load what the latter creates).

And there's Numba, which JIT-compiles python code to LLVM inline and executes the byte code (supporting NumPy, structs etc.):

http://numba.pydata.org/numba-doc/dev/examples.html

Needs some thought on how to deliver the depencies I guess.