2 ms·
Yes thanks, I think that is right... LOAD_FAST and LOAD_CONST are by number, and used for local variables and constants. LOAD_NAME, LOAD_ATTR, and LOAD_GLOBAL
by chubot 10y ago
Yes thanks, I think that is right... LOAD_FAST and LOAD_CONST are by number, and used for local variables and constants.
LOAD_NAME, LOAD_ATTR, and LOAD_GLOBAL are all lookups by name, and are used for everything else: globals, object attributes and methods, modules, etc.
It seems that if Python had a static module system, all the lookups by name could be compiled down into lookups by number.
https://docs.python.org/3/library/dis.html#python-bytecode-instructions https://docs.python.org/3/library/dis.html#python-bytecode-i...
- xapata 10y agoI'm not clear on the status of PEP 509, but it could/should make LOAD_NAME and LOAD_GLOBAL approach the speed of LOAD_FAST. It'll set a flag on the globals dict (or any dict?) that trips when the dict is mutated. Non-mutated dicts can have fast repeated lookups. https://www.python.org/dev/peps/pep-0509/ https://www.python.org/dev/peps/pep-0509/ Dictionaries got some sweet upgrades for v3.6.