Update locals()

Alex Martelli aleax at aleax.it
Sat Apr 27 18:45:50 EDT 2002


holger krekel wrote:
        ...
> Uff. Thanks for the pointer although it is dissappointing. I always
> liked to assume that python does this decision at run time. Doing
> it at compile time may have performance benefits but it prevents
> some nice uses.

It only prevents some terrible hacks that Python is MUCH better
off forbidding.  Python doesn't go out of its way to stop terrible
hacks, but it's sure nice when a crucial optimization has such nice
side effects.  As you've noticed, it's easy to dress up dictionary
lookup by constant keys into attribute-access syntax -- so easy,
that you and I came up with two totally different 3-liner classes
for the same purpose.  And THAT is clean, nice, and useful.  So,
why ever should the dirty, terrible hacks be allowed -- even
though realizing there IS a compile-time is in some measure a
conceptual hurdle when one's first learning Python?


Alex




More information about the Python-list mailing list