Binary search tree
Terry Reedy
tjreedy at udel.edu
Tue Nov 13 00:30:14 EST 2007
"Scott SA" <pydev at rscorp.ab.ca> wrote in message
news:r02010500-1049-7D029806915411DC919E001124DEBE0E@[192.168.69.99]...
| On 11/12/07, Scott SA (pydev at rscorp.ab.ca) wrote:
| I decided to test the speeds of the four methods:
|
| set_example
| s = set()
| for url in urls:
| if not url in s:
| s.add(url)
How is that different in result from
set_example2
s = set(urls)
which would be much faster, faster, I would expect, than
| dict_example
| d = {}
| for url in urls:
| if url in d:
| d[url] = 1
|
| Starting tests with 500000 simulated URLs run 3 times.
| ------------------------------------------------------------
| 'set' example
| run time: 0.5505 seconds
| 'dict' example
| run time: 0.2521 seconds
tjr
More information about the Python-list
mailing list