Iterating over a function call

Diez B. Roggisch deets at
Mon Feb 1 20:52:46 CET 2010

> So.....I'm wondering if there is any interest in an apply() built-in
> function that would work like map() does in 2.x (calls the function
> with each value returned by the iterator) but return nothing.  Maybe
> "apply" isn't the best name; it's just the first one that occurred to
> me.
> Or is this just silly and should I forget about it?

IMHO - yes. Looking up names is what python does all the time, trying to 
microoptimize that away is silly. It is only justfied if you have 
extremely timing-critical code.

And then, all you need to do is to say

def whatever():
   _function = function
   for value in values:

which will reduce lookup-time, as _function is found in locals() rather 
than globals().

And any function that does something worthy will dwarf the second 
namespace-lookup I'd say.


More information about the Python-list mailing list