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

Chris Barker chris.barker at noaa.gov
Wed Feb 21 15:26:32 EST 2018


On Wed, Feb 21, 2018 at 11:55 AM, Elias Zamaria <mikez302 at gmail.com> wrote:

> This is about some minor changes to the bytes, bytearray, and memoryview
> classes. Here is the PEP: https://www.python.org/dev/peps/pep-0467/
>


> I am waiting for this to be merged, or approved, or whatever is the next
> step. Someone on the bug tracker mentioned restarting the discussion on the
> mailing list, so that is what I'm trying to do here. Does anyone have any
> thoughts?
>

+1 all around.

One other thought:

: Addition of optimised iterator methods that produce bytes objects

Maybe it would make sense to have a "byte" type that holds a single byte.
It would be an integer that could only hold values from 0-255. Then the
regular iterator could simply return a bunch of single byte objects.

I can't say I've thought it through, but if a byte is a int with restricted
range, then it could act like an int in (almost?) every context, so there
would be no need for a separate iterator.

I also haven't thought through whether there is any real advantage to
having such a type -- but off the top of my head, making a distinction
between a bytes object that happens to be length-one and a single byte
could be handy. I sure do often wish for a character object.

-CHB

-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180221/ddafc19a/attachment.html>


More information about the Python-Dev mailing list