robin at NOSPAMreportlab.com
Fri Nov 16 20:55:28 CET 2007
Neil Cerutti wrote:
> You are no longer making m copies of active_nodes.
my profiling indicated that the main problem was the removes.
> When you have to make many deletions from the middle of a
> sequence, you would normally choose a linked list. Python doesn't
> provide much support for linked lists, unfortunately.
> Instead, filter your list. It looks like you can't use filter
> directly, so just do it manually.
> for i in xrange(m):
> saved_nodes = 
> for A in active_nodes[:]:
> if not cond:
> active_nodes = saved_nodes
I like this approach, better than mine.
More information about the Python-list