Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AoT Compiler for Python

Tags:

python

llvm

I want to get my Python script working on a bare metal device like microcontroller WITHOUT the need for an interpreter. I know there are already JIT compilers for Python like PyPy, and interpreters like CPython.

However, existing interpreters I've seen (such as CPython) take up large memory (in MB range).

Is there an AOT compiler for Python (i.e. compiling directly to native hardware through intermediary like LLVM)?

I assume such a compiler would enable Python to run much faster compared to existing implementations AND with lower memory footprint. If there is, I wonder why that solution hasn't been popularized.

like image 710
Ravit Sharma Avatar asked Jul 23 '26 03:07

Ravit Sharma


1 Answers

As you already mentioned Cython is an option (However, it is true that the result is big due since the C runtime need to implement the Python functionality together with your program).

With regards to LLVM there was a project by Google named unladen swallow. However, that project is mostly abandoned. You can find some information about it here

Basically it was an attempt to bring LLVM optimizations into the runtime of Cython. E.g JITTING Python code.

Another old alternative was shed skin which compiles Python to C++. Some information about it can be found here.

Yet another option similar to shed skin is to restrict yourself to a subset of the Python language and use micropython.

like image 77
JKRT Avatar answered Jul 24 '26 17:07

JKRT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!