4 ms·
> you look up local variables in hash tables every time they are referenced. This is not what Python does: It maps variable names to integer indices during comp
by pddubs 8y ago
> you look up local variables in hash tables every time they are referenced. This is not what Python does: It maps variable names to integer indices during compilation to bytecode, and the bytecode just takes those embedded constant indices and indexes into an array to obtain a local variable's value.
This is only true for function arguments right? Module level bindings and class and object attributes are looked up in dictionaries. I think the same for variables used in closures too?
- dragonwriter 8y ago> Module level bindings and class and object attributes are looked up in dictionaries. Depends on __slots__, yes?
- xapata 8y agoAnd for any local variables, not just arguments.