which datastructure for fast sorted insert?

Rodrigo Lazo rlazo.paz at gmail.com
Sun May 25 14:02:47 EDT 2008


Stefan Behnel <stefan_ml at behnel.de> writes:

> 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.
>

what about heapq for sorting? 

-- 

Rodrigo Lazo (rlazo)




More information about the Python-list mailing list