[Python-Dev] Idea: Dictionary references
Victor Stinner
victor.stinner at gmail.com
Thu Dec 17 18:32:43 EST 2015
More information about the Python-Dev mailing list
Thu Dec 17 18:32:43 EST 2015
- Previous message (by thread): [Python-Dev] Idea: Dictionary references
- Next message (by thread): [Python-Dev] Idea: Dictionary references
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message (by thread): [Python-Dev] Idea: Dictionary references
- Next message (by thread): [Python-Dev] Idea: Dictionary references
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list