#12029: Fast conversion of ClonableIntArray to list
-----------------------------+----------------------------------------------
Reporter: SimonKing | Owner: sage-combinat
Type: enhancement | Status: new
Priority: major | Milestone: sage-4.8
Component: combinatorics | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author: Simon King
Merged: | Dependencies:
-----------------------------+----------------------------------------------
I think the following is too slow:
{{{
sage: from sage.structure.list_clone import IncreasingIntArrays
sage: I = IncreasingIntArrays()(range(1000))
sage: timeit("L = list(I)", number=10000)
10000 loops, best of 3: 41.8 µs per loop
}}}
My patch adds a method `.list()` (I hope this is the fastest way of
converting a C-int array into a Python list - Cython experts are welcome
to find something better), and it adds an `__iter__()` method that relies
on the `.list()` method.
Note that I tried to have an `__iter__` method that does not call `list()`
but works on the C-array (this is now possible with the new Cython
version), but it turned out to be not faster.
Here are the timings with my patch
{{{
sage: from sage.structure.list_clone import IncreasingIntArrays
sage: I = IncreasingIntArrays()(range(1000))
sage: timeit("L = I.list()", number=10000)
10000 loops, best of 3: 19.4 µs per loop
sage: timeit("L = list(I)", number=10000)
10000 loops, best of 3: 32.9 µs per loop
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12029>
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.