Hi!

I found that L.pop(0) (where L is a list) tends to be relatively slow
in Cython - even if L is cdefined as list.

Google pointed me to some discussion about a Cython optimisation for
L.pop(0), but it is not clear to me whether the optimisation actually
made it into Sage. Can you tell me the status?

Can you show me a way to be faster than what Cython makes of L.pop(0)?
What I found (see below) is faster on small lists, but not so good on
longer lists. Also it doesn't change the list in place.

Best regards,
Simon


%cython
include "python.pxi"
cpdef f(list l):
    return l.pop(0),l
cpdef g(list l):
    return l[0], PyList_GetSlice(l,1,PyList_GET_SIZE(l))

g is faster than f for lists of size 60, at least on sagenb. I am
aware that g does not change l in place - actually I would prefer if
it did.

-- 
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