which datastructure for fast sorted insert?

Stefan Behnel stefan_ml at behnel.de
Sun May 25 13:46:47 EDT 2008


notnorwegian at yahoo.se wrote:
> im writing a webcrawler.
> after visiting a new site i want to store it in alphabetical order.
> 
> so obv i want fast insert. i want to delete duplicates too.
> 
> which datastructure is best for this?

Keep the data redundantly in two data structures. Use collections.deque() to
append and remove as in a queue, and set() to find duplicates.

Again, no ordering, but very fast insert/delete/dup-check.

Stefan



More information about the Python-list mailing list