[Python-3000] List & set comprehensions patch

Nick Coghlan ncoghlan at gmail.com
Thu Mar 8 12:05:23 CET 2007


Greg Ewing wrote:
> Nick Coghlan wrote:
> 
>> One of the comments made on Georg's initial attempt at implementing 
>> these features was that it would be nice to avoid the function call 
>> overhead in the listcomp & setcomp case ... I tried to do that and 
>> essentially failed outright
> 
> Not having seen the code, my thought would be to temporarily
> change the symtab entry so that it refers to a different
> locals slot, compile the nested code with that, and then
> change it back again.
> 
> Did you consider doing something like that and find that
> it wouldn't work?

I didn't, actually - I was looking mostly at the symtable.c code rather 
than tinkering with the data structures the compiler stage uses to emit 
the appropriate LOAD_FAST/STORE_FAST/LOAD_DEREF opcodes.

At this stage though, I've become more concerned about making sure we 
get the semantics the way we want them (i.e. the same as generator 
expressions) before trying to recover some of the speed lost due to the 
introduction of the anonymous function.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-3000 mailing list