Fastest way to count your iterations?
adalke at mindspring.com
Mon Jul 28 21:08:41 CEST 2003
> If you're writing a simple script and you want to give an update of
> its progress... Is this the fastest way to do it (assuming that what
> you're iterating through is very, very long and the time to process
> each item is relatively short)...
What you wrote is very standard, so I would suggest using it.
However, if you want performance, try variations on
def counter(items, f, sep=1000):
next_item = iter(items).next
values = range(sep)
for i in range(0, sys.maxint, sep):
for j in values:
dalke at dalkescientific.com
More information about the Python-list