But why does the programmer need to do this? Should the language interpreter be able to implicitly perform this operation?
Isn't that what the .pyc files are for, so that it doesn't need to perform lookups like this at runtime?
Isn't that what the .pyc files are for, so that it doesn't need to perform lookups like this at runtime?
The language was designed with expressiveness in mind, and it often comes at the expense of speed. Lua and Nim seem to strike a much better balance, and even JavaScript if you avoid the performance killers like "with".
Who? Why?
Most of those are rare, but feasible. Monkeypatching a global as a side effect even rarer, but I think I've done it at some point.
for animal in circus.animals:
circus.next_free_clown.assign(animal)
# circus.next_free_clown changes in every iteration.pyc files are created for "faster importing", and they remove having to parse and "compile to bytecode" the .py files.
and then the pre-looked-up version of method are now wrong.