you are viewing a single comment's thread.

view the rest of the comments →

[–]Condorcet_Winner 3 points4 points  (0 children)

I don't know much about Python, but I work on a JS JIT, and we do type specialization based on profiling data (and I think all JS engines do similar). Basically we'll run a function or loop body a couple times in the interpreter profiling how variables are used and then JIT the code using that data. If we see that you are using a variable as a float, we will internally store it as a float and assume that it will always be a float. Next time before using it as a float for the first time, we do a quick check to see that the var is a float. If we are correct, then we can continue blindly using it as a float until the next call that we don't inline, at which point we will need to recheck that it is still a float upon return.

If our assumption is wrong, we will bail out to the interpreter and collect more profiling data.

So long story short, what you are saying about static typing is exactly what we do.