Generator slower than iterator?
Federico Moreira
federico at linux.com.uy
Tue Dec 16 11:48:54 EST 2008
The defaultdict option looks faster than the standard dict (20 secs aprox).
Now i have:
#############################
import fileinput
import sys
from collections import defaultdict
match_counter = defaultdict(int)
for line in fileinput.input(sys.argv[1:]):
match_counter[line.split()[0]] += 1
#############################
About generators, now i get the idea of when use them and when not.
Thanks MRAB, Lie and Gary.
Now not only is faster but also cleaner and easy to understand =)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081216/0bfcce1a/attachment-0001.html>
More information about the Python-list
mailing list