c[:]()

Terry Reedy tjreedy at udel.edu
Mon Jun 4 14:45:44 EDT 2007


"Warren Stringer" <warren at muse.com> wrote in message 
news:00b301c7a690$25af37d0$240110ac at Muse...
|> "Marc 'BlackJack' Rintsch" <bj_666 at gmx.net> wrote in message
| > news:pan.2007.06.03.20.03.25.278011 at gmx.net...
| > || Warren Stringer wanted to call the functions just for the side 
effects
| > | without interest in the return values.  So building a list of return
| > | values which is immediately thrown away is a waste of time and 
memory.
| >
| > Also unnecessary: for f in callables: f()
|
| What do you mean?

That if you want to call each of a sequence of proceedures (functions 
without a meaning return), as you have indicated and do so again, then the 
above is the simple, direct way to do so.  Using 'c' instead of 
'callables', as in the subject line, would reduce the number of characters

[snip]
| It sounds like list comprehension may be slower because it builds a list
| that never gets used.

A list comprenhension is for building a list that will be used.

| I'm curious if eval statements are faster than def
| statements? Any bytecode experts?

Eval expressions (not statements) and def statements do different things 
and hence comparing their speed make no sense to me.  In any case, speed 
comparisions that you really care about are best done on a particular 
target system.

Terry Jan Reedy







More information about the Python-list mailing list