Fastest way to apply a function to an iterable
Shashank Singh
shashank.sunny.singh at gmail.com
Wed May 26 15:48:46 EDT 2010
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:
itemlist = [i1, i2, i3....]
for item in itemlist: item.save()
It might be squeezing too much but is it possible to do it more efficiently
by pushing the looping inside the C code
and achieve some gains as is done by using map in place of a for loop when
the return values need to be saved?
Any suggestions will be appreciated.
TIA
--
Regards
Shashank Singh
Senior Undergraduate, Department of Computer Science and Engineering
Indian Institute of Technology Bombay
shashank.sunny.singh at gmail.com
http://www.cse.iitb.ac.in/~shashanksingh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100527/7df4cecf/attachment.html>
More information about the Python-list
mailing list