"col speed" <ajarnco...@gmail.com> wrote

Just my twopenneth, I'm a noob and I'm not going to try such a big file on
my old machine, but:

1. Maybe create a *set* from the wordlist, loop through that, so you call
"count" on wordlist only once.  OR

This would be an improvement but still involves traversing the entire
list N times where N is the number of unique words.

2. Use collections.defaultdict(int) and loop through wordlist and do
dic[word] += 1

This is what his second version is supposed to do and is the
best solution since it only involves a single trasverse of the file.

Alan G.

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to