[Python-Dev] PEP 467 (Minor API improvements for binary sequences) - any thoughts?

Nick Coghlan ncoghlan at gmail.com
Thu Mar 1 00:51:30 EST 2018

On 28 February 2018 at 03:15, Ethan Furman <ethan at stoneleaf.us> wrote:

> On 02/26/2018 11:34 PM, Elias Zamaria wrote:
> I don't know how I would feel working on something so general, of use to
>> so many people for lots of different purposes.
>> Do I know enough about all of the use cases and what everyone wants? I am
>> not completely against it but I'd need to
>> think about it.
> Part of the PEP writing process is asking for and collecting use-cases;
> if possible, looking at other code projects for use-cases is also useful.
> Time needed can vary widely depending on the subject; if I recall
> correctly, PEP 409 only took a few days, while PEP 435 took several weeks.
> PEP 467 has already gone through a few iterations, so hopefully not too
> much more time is required.

One of the main developments not yet accounted for in the PEP is the fact
that `memoryview` now supports efficient bytes-based iteration over
arbitrary buffer-exporting objects:

    def iterbytes(obj):
        with memoryview(obj) as m:
            return iter(m.cast('c'))

This means that aspect of PEP 467 will need to lean more heavily on
discoverability arguments (since the above approach isn't obvious at all
unless you're already very familiar with the use of `memoryview`), since
the runtime benefit from avoiding the upfront cost of allocating and
initialising two memoryview objects by using a custom iterator type instead
is likely to be fairly small.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180301/b3c4c4b5/attachment.html>

More information about the Python-Dev mailing list