Execution speed question

Suresh Pillai stochashtic at yahoo.ca
Mon Jul 28 16:48:28 CEST 2008

On Mon, 28 Jul 2008 15:04:43 +0200, Suresh Pillai wrote:

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

Okay, please consider this my one absolutely stupid post for the year.  
I'd like to pretend it never happened but unfortunately the web doesn't 
allow that.  Having never used sets, I unfort read something that lead to 
it, but ...

More information about the Python-list mailing list