Function application optimization.

Peter Otten __peter__ at web.de
Fri Dec 12 07:57:22 EST 2003


Jacek Generowicz wrote:

> Given
> 
>   fncs = [func1, func2, ..., funcN]
>   args = [arg1,  arg2,  ..., argN]
> 
> How should one spell
> 
>   results = map(lambda f,a: f(a), fncs, args)
> 
> in order to get the result most quickly ?
> 

If you can afford to destroy the args list, a tiny speed gain might be in
for you (not verified):

for index, func in enumerate(fncs):
    args[index] = func[index]       

Peter




More information about the Python-list mailing list