#11118: Add a cache for .list() method in FiniteEnumeratedSet
------------------------------+---------------------------------------------
   Reporter:  hivert          |       Owner:  sage-combinat                 
       Type:  enhancement     |      Status:  needs_review                  
   Priority:  major           |   Milestone:  sage-4.7                      
  Component:  combinatorics   |    Keywords:  list FiniteEnumeratedSet cache
     Author:  Florent Hivert  |    Upstream:  N/A                           
   Reviewer:                  |      Merged:                                
Work_issues:                  |  
------------------------------+---------------------------------------------

Old description:

> There are two way to get the list of the elements of a
> {{{FiniteEnumeratedSet}}}:
> {{{
>      list(FSet)
>      FSet.list()
> }}}
> The first case uses {{{FSet.__iter__}}} which is slow in many practical
> case, for example because of deep {{{yield}}} recursion...
>
> After a discussion with Nicolas, We decided the following: In the second
> case, we assume that there is a need for speed and therefore we take
> chance to cache the list.

New description:

 There are two way to get the list of the elements of a
 {{{FiniteEnumeratedSet}}}:
 {{{
      list(FSet)
      FSet.list()
 }}}
 The first case uses {{{FSet.__iter__}}} which is slow in many practical
 case, for example because of deep {{{yield}}} recursion...

 After a discussion with Nicolas, We decided the following: In the second
 case,
 we assume that there is a need for speed and therefore we take chance to
 cache
 the list. Here is an example of speedup (needs conbinat patches
 installed):
 {{{
 sage: %timeit list(BinaryTrees(5))
 25 loops, best of 3: 24.7 ms per loop
 sage: %timeit BinaryTrees(5).list()
 625 loops, best of 3: 6.7 µs per loop
 }}}

--

Comment(by hivert):

 Here is an advanced solution. Please review.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11118#comment:2>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to