Re: split an iteration

2005-04-01 Thread Peter Otten
Robin Becker wrote: eg for  e = enumerate([0,1,2,3,4,5])  for i,a in e: ... if a==3: break ...  for i,a in e: ... print i,a ... 4 4 5 5 I think the second loop needs to start at 3 ie the split needs to be start, limit semantics It would be nice to be able to fix

Re: split an iteration

2005-03-31 Thread Peter Otten
Robin Becker wrote: Is there a fast way to get enumerate to operate over a slice of an iterable? I think you don't need that here: e = enumerate(active_nodes) for insert_index, a in e: # ... for index, a in e: # ... Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: split an iteration

2005-03-31 Thread Raymond Hettinger
[Robin Becker] This function from texlib in oedipus.sf.net is a real cpu hog and I determined to see if it could be optimized. def add_active_node(self, active_nodes, node): Add a node to the active node list. The node is added so that the list of active nodes is always

Re: split an iteration

2005-03-31 Thread Robin Becker
Peter Otten wrote: Robin Becker wrote: Is there a fast way to get enumerate to operate over a slice of an iterable? I think you don't need that here: e = enumerate(active_nodes) for insert_index, a in e: # ... for index, a in e: # ... Peter I tried your solution, but I think we miss the

Re: split an iteration

2005-03-31 Thread Robin Becker
Raymond Hettinger wrote: [Robin Becker] This function from texlib in oedipus.sf.net is a real cpu hog and I determined to see if it could be optimized. def add_active_node(self, active_nodes, node): Add a node to the active node list. The node is added so that the list of active nodes is