Re: Fastest way to apply a function to an iterable

2010-05-26 Thread Stefan Behnel
Shashank Singh, 26.05.2010 23:16: > I probably didn't state the problem properly. I was assuming the > availability of a static method that could be passed on to map based > solution (or imap for that matter). > > The question was, if one wants to apply a function on each member of list > and dis

Re: Fastest way to apply a function to an iterable

2010-05-26 Thread Shashank Singh
On Thu, May 27, 2010 at 1:56 AM, Stefan Behnel wrote: > If all items have the exact same type, you can get away with an unbound > method: > >class MyType(object): >... >def safe(self): >... > >itemlist = [ MyType() for i in range(20) ] > ># this is what you

Re: Fastest way to apply a function to an iterable

2010-05-26 Thread Peter Otten
Stefan Behnel wrote: > Shashank Singh, 26.05.2010 21:48: >> What is the most efficient way of applying a function to all the elements >> of an iterable while discarding the >> result (i.e. operations are done only for side-effects). >> >> For example if I want to save all elements in a list of ite

Re: Fastest way to apply a function to an iterable

2010-05-26 Thread Stefan Behnel
Shashank Singh, 26.05.2010 21:48: What is the most efficient way of applying a function to all the elements of an iterable while discarding the result (i.e. operations are done only for side-effects). For example if I want to save all elements in a list of items (and am not interested in what sa

Fastest way to apply a function to an iterable

2010-05-26 Thread Shashank Singh
What is the most efficient way of applying a function to all the elements of an iterable while discarding the result (i.e. operations are done only for side-effects). For example if I want to save all elements in a list of items (and am not interested in what save() returns), the simplest way is: