Execution speed question
Suresh Pillai
stochashtic at yahoo.ca
Mon Jul 28 09:04:43 EDT 2008
On Mon, 28 Jul 2008 10:44:18 +0200, Suresh Pillai wrote:
> Since I am doing A LOT of loops over the nodes and the number of nodes
> is also huge, my concern using sets is that in order to iterate over the
> set in each step of my simulation, the set items need to be converted to
> a list every time. So while removal from a set is much cheaper than say
> from a list, what about this conversion overhead in order to iterate
> over the items.
I could of course use the old trick of using a dictionary with 'None'
values and then using iterkeys(). But I thought sets were supposed to
replace this. So maybe I should be asking a more basic question: is
there any way to iterate over the items in a set other than converting to
a list or using the pop() method.
More information about the Python-list
mailing list