2015-12-17 23:17 GMT+01:00 Andrew Barnert via Python-Dev <python-dev at python.org>: > Builtins do two dict lookups. > > So, the only thing you can optimize there is builtins. But maybe that's worth it. FYI I implemented an optimization in FAT Python to avoid lookups for builtin functions, builtin functions are copied to code constants at runtime: https://faster-cpython.readthedocs.org/fat_python.html#copy-builtin-functions-to-constants It's nothing new, it's the generalization of common hacks, like 'def func(len=len): return len(3)'. The optimization is restricted to loading builtin symbols which are not expected to be modified ;-) (Right now the optimization is disabled by default, because the optimizer is unable to detect when builtins are modified in the current function, and so it breaks the Python semantic.) > Class attributes (including normal methods, @property, etc.) do two or more dict lookups--first the instance, then the class, then each class on the class's MRO. Note: Types have an efficient cache for name lookups ;-) Thanks for this cache, it's no more an issue to have a deep hierarchy of classes. Victor
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4