This is my slide at PyCon TW 2017, topic is "PyPy's approach to construct domain-specific language runtime", and this slide contains some experiments and benchmark related to PyPy, a JIT-enabled version of Python
and the way PyPy develop is different • CPython • Focus on Python3, only maintain Python2 when security issue pops up • PyPy • Focus on PyPy2, also updating PyPy3, but it's not their main development
time, and compile it with JIT-Enabled takes even more. • Usually takes 30min up • And you need at least 4G RAM to compile it on 64-Bit Machine, make sure you have enough RAM for this, or it may be killed by system
into IR • Then you can choose to do Optimize in IR • Finally, turn your IR into Python Code, and compile it with PyPy to generate a binary file Brainf*ck Code IR Python Code Binary File
to Python • trans.py -> Main program • python trans.py <input> <output> <optmode> • optmode 1 to open optimization, 0 to not to • opt.py -> Optimize tricks
", means that we have to do "mem[p] += 1" five times • But because we have IR, so we can change the instruction to "mem[p] += 5" • When it comes to “+ - > <“, this trick can apply
that we have a pointer indicating where we are now, and pointer usually move a lot • What if we can calculate offset for Instructions directly, so we don't need to move the pointer around
• Because JIT needs to warm-up and Analysis Maybe warm-up can take more time than your code actually run • And it's import to avoid to record the warm-up time when you want to do some benchmarking
know how difficult it is for you to import PyPy and JIT into your project, then you're good to go! • BTW, file size of executable with JIT Enabled is bigger than the one with No-JIT