Binary search tree

"Martin v. Löwis" martin at v.loewis.de
Mon Nov 12 09:23:43 CET 2007


> Now, I can see that this method has some superfluous data (the `1`
> that is assigned to the dict). So I suppose this is less memory
> efficient. But is this slower then? As both implementations use hashes
> of the URL to access the data. Just asking out of curiosity ;)

Performance-wise, there is no difference in the implementations.
What matters when comparing programs one-by-one is how many method
calls you need. In this example, the dictionary is slightly faster
in my measurements, since for the set, you need to perform a lookup
of .add, whereas the access to __setitem__ for the dict need no
additional dictionary lookup.

Regards,
Martin



More information about the Python-list mailing list