More on "with" statement

Steve Holden sholden at holdenweb.com
Mon Jul 16 08:06:55 EDT 2001


"Erik Max Francis" <max at alcyone.com> wrote in message
news:3B4FF355.AFC80981 at alcyone.com...
> Roman Suzi wrote:
>
> > > That's just plain more efficient.  Four additions and one multiply
> >
> > four?
>
> Yes, typo.  Three, obviously.
>
> > The same with "with": it could make name-resolving more efficient
> > by allowing searching some namespaces ahead of locals() and
> > globals()...
>
> Or you could just make a temporary assignment.  Same thing going on, no
> need for a new keyword and ambiguous code.
>

As in:

for lvar in [some.horrendous.long.reference[3][12]]:
    lvar.this = 17
    lvar.that = 21

which, IIRC, was pointed out bu the timbot about three months ago.

But a lot of this thread has ignored the fact that Python's dynamic nature
makes a "with"-type construct impossible to compile with any efficiency,
since the contents of the namespace cannot be predicted purely as a result
of static program analysis.

regards
 STeve
--
http://www.holdenweb.com/








More information about the Python-list mailing list