Execution speed question
iainking at gmail.com
Fri Jul 25 17:08:57 CEST 2008
On Jul 25, 3:39 pm, Suresh Pillai <stochash... at yahoo.ca> 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 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 which nodes to turn ON until after all the
> probabilities are calculated (lets say we take the top m for example).
> In this case, the second and third will perform worse as the second one
> will require a remove from the list after the fact and the third will
> require another loop through the nodes to build the new list.
So you need to loops through twice regardless? i.e. loop once to
gather data on off nodes, do some calculation to work out what to turn
on, then loop again to turn on the relevant nodes? If so, then I
think the functions above remain the same, becoming the 2nd loop.
Every iteration you do a first loop over the off_nodes (or them all
for (1)) to gather the data on them, perform your calculation, and
then perform one of the above functions (minus the setup code at the
begining; basically starting at the 'for') as a second loop, with the
goes_on function now returning a value based on the calculation
(rather than the calculation itself as I had it). Performance should
More information about the Python-list