3 ms·
you can lookup once and inline the method, and only keep a flag to check if you need to invalidate that. Pypy & other jits al do this kind of things all the ti
by riffraff 16y ago
you can lookup once and inline the method, and only keep a flag to check if you need to invalidate that.
Pypy & other jits al do this kind of things all the time :)
But you don't need a jit: you can partially execute the code and determine that no changes were happening in the referenced globals, thus the inlining becomes possible.
There is quite a bit of literature on the issue of using partial evaluation for optimizing dynamic/reflective languages.
- edanm 16y agoInteresting. What are the best sources for learning what kind of optimizations are actually implemented in practice in Python?
- riffraff 16y agowell neither of the above, in standard python, but the pypy project has _a lot_ of interesting stuff http://codespeak.net/pypy/dist/pypy/doc/extradoc.html http://codespeak.net/pypy/dist/pypy/doc/extradoc.html