On Fri, Dec 20, 2013 at 4:06 AM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > Should some implementation decide to compile that away as dead > code, it would be perfectly allowed to. (Well, assuming that it > determined first that locals() actually was the built-in and not some > substitute, either by static analysis or runtime testing.)
Hmm. I'm not sure how safe it is to optimize that sort of thing away in Python. Is there any way to be truly sure that locals is still the built-in, and if there isn't, is there any advantage to optimizing it out with some sort of check to see if it should be de-optimized now? But yes, in theory you're right. Mutating locals() could be optimized out. ChrisA -- https://mail.python.org/mailman/listinfo/python-list