On 03/08/11 00:08, Chris Angelico wrote: > With the local-variable-snapshot technique ("len = len"), can anything > be optimized, since the parser can guarantee that nothing ever > reassigns to it? If not, perhaps this would be a place where something > might be implemented: > [...]
Yes, it can. The parser can know when it is reassigned to just by looking at the one function, and even if it didn't, or if it were reassigned, it wouldn't make much of a difference because the interpreter would still only have to fetch one of a set of locals known at compile time, which can be (is? I'm not sure) as simple as an array lookup: two pointers being dereferences instead of one. Chris Rebert raises a very important point though: Python dynamic namespaces make optimising variable lookup comparatively difficult, but not impossible: good JavaScript JITs are smart enough, so a good Python JIT could be as well. Thomas -- http://mail.python.org/mailman/listinfo/python-list