Pyjiting is a experimental Python-JIT compiler, which is the product of my undergraduate thesis. The goal is to implement a light-weight miniature general-purpose Python JIT compiler.
- Use llvmlite as Backend, support Python 3.9 and up, fix some errors in the numpile tutorial.
- Support calls the Python function(code in
.py
, need manually register, just add@reg
) from the JITed function(llvm binary) based on TypeHints. (Seeexample_find_primes.py
) - Implement basic functions, such as Compare operators, Mathematical operators, etc.
- Implement
if
expressions. - Implement
for
expressions, and allowbreak
. - Implement
while
expressions. - Implement recursion.
You can find the source code of these test samples in the root directory.
My test environment:
CPU: [email protected]
Memory: 32GB DDR4 3200Mhz
OS: Windows 10 21H2 64bit
Python 3.9.9 64bit
LLVMLite 0.37.0
fib_jit(40) = 102334155 (cost time: 169.3246364593506 ms)
fib_nojit(40) = 102334155 (cost time: 26464.3042087554929 ms)
rate: 156.29328821921743
find_primes_jit(100000) = 0 (cost time: 3358.8650226593018 ms)
find_primes_nojit(100000) = 0 (cost time: 37986.81926727295 ms)
rate: 11.309421191685097
is_prime_jit(169941229) = True (cost time: 958.0211639404297 ms)
is_prime_nojit(169941229) = True (cost time: 13279.908418655396 ms)
rate: 13.861811114938112
loop_jit(100000000) = 200000000 (cost time: 0.0 ms)
loop_nojit(100000000) = 200000000 (cost time: 7256.179332733154 ms)
rate: Infinite
test_while_jit(100000000) = 100000000 (cost time: 0.0 ms)
test_while_nojit(100000000) = 100000000 (cost time: 7198.246292114258 ms)
rate: Infinite
Inspired by numpile tutorial and continue to work on this basis.
I am deeply grateful to professor Mr Takeshi Ogasawara gave me many inspirations and appropriate advice.