On Oct 19, 12:42 pm, Simon King <[email protected]> wrote:
> In contrast to my first tests, it meanwhile seems to me that the
>   L[0], PyList_GetSlice(L,1,PyList_GET_SIZE(L))
> idiom is faster than deque in my applications. Recall that this was
> the fastest replacement for pop(0), if the lists are not too long
> (which will probably be the case in my applications).
>
> After all, "collections" is Python, not Cython.

It sounds like you are in a sufficiently low range that a worse order
algorithm with lower overhead is better. However, in other situations:
"collections" is python, but the actual implementations are in
_collections, which is an extension module. By writing the right
header files, you should be able to call the routines in there with
the same low overhead as PyList_* etc. (provided those are not
macros). It's conceivable you could still write better code for
special situations, but otherwise I'd expect that interfacing
_collections.deque directly should provide you with a good optimized
implementation (either via doubly linked list or via circular buffer.
I don't know what they use)

Access to lists is always going to be a little faster for the same
reason why "pop" has worse complexity: one less level of indirection.

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