3 ms·
Python might have changed since this was written, but on my machine, with any number, it finishes in 0.0s! My understanding was that to access a variable, pyth
by smallpipe 6y ago
Python might have changed since this was written, but on my machine, with any number, it finishes in 0.0s!
My understanding was that to access a variable, python does a dictionary lookup to match the name to a memory location, which would explain what happens with an older python.
- wwright 6y agoThat happens for global lookups, but methods should use a stack-like lookup for local variables which should be much faster IIRC (Personally, I really question the extremely-dynamic-by-default design of that generation of languages; is being able to treat globals as a dictionary occasionally worth forcing a key lookup on every single global use?)