Populating a dictionary, fast

Istvan Albert istvan.albert at gmail.com
Sun Nov 11 22:40:42 EST 2007


On Nov 11, 11:51 am, Michael Bacarella <m... at gpshopper.com> wrote:

> and see it take about 45 minutes with this:
>
> $ cat cache-keys.py
> #!/usr/bin/python
> v = {}
> for line in open('keys.txt'):
>         v[long(line.strip())] = True

On my system (windows vista) your code (using your data) runs in:

36 seconds with python 2.4
25 seconds with python 2.5
39 seconds with python 3000


i.





More information about the Python-list mailing list