[Python-Dev] O(1) deletes from the front of bytearray (was: Re: Adding bytes.frombuffer() constructor to PEP 467 (was: [Python-ideas] Adding bytes.frombuffer() constructor)

Antoine Pitrou solipsis at pitrou.net
Thu Oct 13 08:02:22 EDT 2016


On Wed, 12 Oct 2016 14:14:48 -0700
Nathaniel Smith <njs at pobox.com> wrote:
> 
> The proposal is that it should be documented as being part of the
> language spec starting in 3.4 (or whatever). So applications that
> support Python 2.7 can't rely on it, sure. But if I have an
> application that requires, say, 3.5+ but I don't want to depend on
> CPython-only implementation details, then I'm still allowed to use it.
> 
> AFAIK basically the only project that would be affected by this is
> PyPy, and I when I asked on #pypy they said:
> 
> <cfbolz> njs`: I think we either plan to or already support this
> 
> so I'm not sure why this is controversial.

The main reason it could be controversial is if someone finds out
another optimization that is made difficult or impossible by the O(1)
delete-at-front guarantee.  That sounds unlikely, though, since the
general structure of a bytearray is constrained by other factors as
well (such as the C API and the buffer API).

By the way, to answer another question, the reason this wasn't made
part of the spec originally is that the feature in itself was already
contentious (see issue tracker discussion).  Now that more people seem
to get interested in network programming, they seem to understand the
point ;-)

Regards

Antoine.




More information about the Python-Dev mailing list