Experiences/guidance on teaching Python as a first programming language

Chris Angelico rosuav at gmail.com
Thu Dec 19 18:18:21 CET 2013


On Fri, Dec 20, 2013 at 4:06 AM, Steven D'Aprano
<steve+comp.lang.python at 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



More information about the Python-list mailing list