Re: Execution speed question

2008-07-29 Thread Suresh Pillai
On Mon, 28 Jul 2008 16:48:28 +0200, Suresh Pillai wrote: > 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 tha

Re: Execution speed question

2008-07-28 Thread Suresh Pillai
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 >> th

Re: Execution speed question

2008-07-28 Thread Suresh Pillai
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 >

Re: Execution speed question

2008-07-28 Thread Suresh Pillai
On Fri, 25 Jul 2008 17:05:27 -0400, Terry Reedy wrote: > If the nodes do not have to be processed in any particular order, then > you could keep them either in a dict, with the value being either On or > Off (True,False)(plus connection data) or a pair of sets, one for On and > one for Off. The a

Re: Execution speed question

2008-07-28 Thread Suresh Pillai
On Fri, 25 Jul 2008 05:46:56 -0700, Iain King wrote: > or 3. build a new list every iteration intead of deleting from the old > one: > > while processing: > new_off_list = [] > for x in off_list: > if goes_on(x): > on_list.append(x) > else: > new_of

Re: Execution speed question

2008-07-28 Thread Suresh Pillai
On Fri, 25 Jul 2008 09:22:06 -0600, Matthew Fitzgibbons wrote: > As for different data structures, it largely depends on how you need to > access the data. If you don't need to index the data, just loop through > it, you might try a linked list. The performance hit in (2) is coming > from the list

Re: Execution speed question

2008-07-28 Thread Suresh Pillai
On Fri, 25 Jul 2008 08:08:57 -0700, Iain King wrote: > On Jul 25, 3:39 pm, Suresh Pillai <[EMAIL PROTECTED]> wrote: >> That's a good comparison for the general question I posed. Thanks. >> Although I do believe lists are less than ideal here and a different >&g

Re: Execution speed question

2008-07-25 Thread Suresh Pillai
On Fri, 25 Jul 2008 16:51:42 +0200, Fredrik Lundh wrote: > Unless I'm missing something, your example keeps going until it's > flagged *all* nodes as "on", which, obviously, kills performance for the > first version as the probability goes down. The OP's question was about > a single pass (but he

Re: Execution speed question

2008-07-25 Thread Suresh Pillai
That's a good comparison for the general question I posed. Thanks. Although I do believe lists are less than ideal here and a different data structure should be used. To be more specific to my case: As mentioned in my original post, I also have the specific condition that one does not know wh

Execution speed question

2008-07-25 Thread Suresh Pillai
I am performing simulations on networks (graphs). I have a question on speed of execution (assuming very ample memory for now). I simplify the details of my simulation below, as the question I ask applies more generally than my specific case. I would greatly appreciate general feedback in te