Hi Robert,

On 20 Okt., 06:59, Robert Bradshaw <[email protected]>
wrote:
> There isn't one as pop(0) on a list requires re-copying the entire
> contents of the list. You could use numpy arrays, where slices such as
> L[1:] are views. A cython-implemented linked list may perform well
> here as well.

Some tests in pure Python seem to indicate that numpy arrays are
slower than lists.
In particular, I need containment test and pop (or slices), and the
items are types:

sage: import numpy
sage: from numpy import array
sage: A = CommutativeAlgebras(QQ); B = HopfAlgebras(QQ); C = Fields();
D = FiniteEnumeratedSets()
sage: L1=A.parent_class.mro()
sage: L2=B.parent_class.mro()
sage: L3=C.parent_class.mro()
sage: L4=D.parent_class.mro()
sage: A1 = array(L1)
sage: A2 = array(L2)
sage: A3 = array(L3)
sage: A4 = array(L4)
sage: c = Algebras(QQ).parent_class
sage: timeit("c in L2")
625 loops, best of 3: 344 ns per loop
sage: timeit("c in A2")
625 loops, best of 3: 14 µs per loop
sage: timeit("c in L4")
625 loops, best of 3: 555 ns per loop
sage: timeit("c in A4")
625 loops, best of 3: 12.9 µs per loop
sage: timeit("L4[1:]")
625 loops, best of 3: 835 ns per loop
sage: timeit("A4[1:]")
625 loops, best of 3: 1.07 µs per loop

Will the picture be different when cimporting numpy.ndarray in Cython?

Best regards,
Simon

-- 
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-support
URL: http://www.sagemath.org

Reply via email to