[Python-Dev] collections module

Kurt B. Kaiser kbk at shore.net
Sun Jan 11 17:10:36 EST 2004


"Martin v. Loewis" <martin at v.loewis.de> writes:

> That will cause a major ABI incompatibility, as all modules
> that use PyList_GET_SIZE need to be recompiled. In addition,
> it causes a slow-down for the standard use of lists. So you
> would make the general case slower, just to support a
> special case. Why are you proposing that?

I'm not proposing it, I'd have to provide an implementaton to do that :-)

I just asked the question, "Why not a circular buffer implementation?"
Tim has been patient enough to get my education on that subject
started.

ob_size should continue to be the number of pointers to objects.  The
GET_ITEM/SET_ITEM macros are more problematic in terms of overhead
because an additional memory access would be required to get the
current size of the block containing the pointer vector.

As Tim said, other methods under consideration could also change the ABI.

If the overall slowdown of lists to get fast queues was 5%, that would
no doubt be unacceptable.  If it was 0.5%, I imagine it would be
acceptable?

Note that if no pop(0)'s are ever done on the list there is no wrap
around and the slowdown is limited to the access of blocksize plus a
test; no modulo arithmetic is necessary.  This is also the case if the
list doesn't grow and items are only removed, including list[0].  And
in the latter case, the memmoves associated with internal deletions
will dominate the performance in all implementations.

-- 
KBK



More information about the Python-Dev mailing list