3 ms·
Can eval ever increase performance? I’m thinking that for some types of abstractions you can end up with highly nested, indirect calls, and if you can instead g
by tobr 8y ago
Can eval ever increase performance? I’m thinking that for some types of abstractions you can end up with highly nested, indirect calls, and if you can instead generate new code as needed, maybe it could speed things up? Are there any mainstream examples of this?
- __s 8y ago2 examples for optimizing for LuaJIT: https://github.com/pygy/LuLPeg https://github.com/pygy/LuLPeg https://github.com/pygy/strung.lua https://github.com/pygy/strung.lua
- Veedrac 8y agoPython uses/used eval for namedtuple at least in part for performance.
- xapata 8y agoUsed. Raymond revised the implementation.
- hyperpape 8y agoI think the Python falcon web server uses eval to produce direct python that executes routing code at run time. I don't have any reason to think it can't be beat, but it is relatively fast for something done in Python. More generally, generating code is used for a lot of regex engines, though it may happen before runtime.
- nine_k 8y agoThis looks like a compilation step. If you cannot have your language implementation generate some kind of optimized code statically, you can do it yourself dynamically.