-
-
Notifications
You must be signed in to change notification settings - Fork 674
Closed
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
CC: @sagetrac-sage-combinat
Component: combinatorics
Keywords: list FiniteEnumeratedSet cache Cernay2012
Author: Florent Hivert
Reviewer: Nicolas M. Thiéry
Merged: sage-5.0.beta4
Issue created by migration from https://trac.sagemath.org/ticket/11118