The "normal way" is by far the best way, although itertools offers a recipe for consumption for whatever reason you may need it:
import collections from itertools import islice def consume(iterator, n): "Advance the iterator n-steps ahead. If n is none, consume entirely."
This can be used as:
consume(imap(func, my_list), None)
This function does the fastest work since it avoids python for loop overhead by using functions performed on the C side.
source share