In this post, I will show simple loop, its alternative implementation with imaginary JIT
compiler that “optimizes” its internals. I will also show speed benchmark.
Loops are core building blocks in every program.
In Python, they iterate over sequence.
However in C, they keep looping while some condition is meet.
Take for example:
Tracing JIT would recognize loop and try to optimize it.
If code above is in C, there is really no need to do such a thing.
However, if your code is in Python, JIT will dramatically
improve speed over loops which “captured” variables stay with same type.
Anyway, we will keep C example, and try to work on it.
Code above would be JIT compiled to look like following: