>
> > Are you really getting benefit from storing the state (i.e., the actual 
> > iterator) on the parent itself? (I see you haven't made ClusterAlgebra 
> > UniqueRepresentation, so it's not an immediate bug to have it this way) 
> > Perhaps it's cleaner to hand out iterator objects that are kept track 
> > of in the relevant loop. That iterator would then just die whenever the 
> > frames of a KeyboardInterrupt exception are discarded and the flawed 
> > state wouldn't persist. 
>
> The main benefit I get from storing the iterator is that, if the user is 
> careful in calling the various functions with reasonable stopping points, 
> the 
> code never has to start searching from scratch. For example currently 
>
>     sage: A = ClusterAlgebra(['A',2,1]) 
>     sage: A.explore_to_depth(10) 
>     sage: A.explore_to_depth(11) 
>
> effectively only traverses the tree once to depth 11. If I were not to 
> store 
> the iterator then I would be traversing the tree twice. And unfortunately 
> this is expensive. 
>

The method graded_component does exactly what you want. See 

https://github.com/sagemath/sage/blob/master/src/sage/sets/recursively_enumerated_set.pyx#L607
 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to