which datastructure for fast sorted insert?
I V
ivlenin at gmail.com
Sun May 25 19:30:49 EDT 2008
On Sun, 25 May 2008 15:49:16 -0700, notnorwegian wrote:
> i meant like set[pos], not iterate but access a specific position in the
> set.
If you need to access arbitrary elements, use a list instead of a set
(but you'll get slower inserts). OTOH, if you just need to be able to get
the next item from the set, you can use an iterator:
> now i have to do:
> s = toSet.pop()
> toSet.add(s)
i = iter(toSet)
s = i.next()
> if i want to get the url of the next item in a set, how would i do that?
> i can do this with a list:
>
> def scrapeSitesX(startAddress, toList, listPos): return
> scrapeSites(toList[listPos], toList, listPos+1) to use recursion with a
> list.
> i can work around that but it doesnt get as elegant.
Do you have to use recursion here? Why not:
for site in toList:
scrape(site)
More information about the Python-list
mailing list