I think the chances of a "byte" object are about as good as the chances of a character object (though one can always implement such in C extensions, that wouldn't build them into the syntax). The fact that characters are single-byte strings is responsible for certain anomalies with (e.g.) the __contains__ operator (list elements aren't lists, but string element are strings), but overall the choices made lead to sensible, comprehensible code.

regards
 Steve

Steve Holden

On Wed, Feb 21, 2018 at 8:26 PM, Chris Barker <chris.barker@noaa.gov> wrote:
On Wed, Feb 21, 2018 at 11:55 AM, Elias Zamaria <mikez302@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@noaa.gov

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/steve%40holdenweb.com