[Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview
Ethan Furman
ethan at stoneleaf.us
Mon Jul 18 15:58:17 EDT 2016
On 06/07/2016 02:34 PM, Koos Zevenhoven wrote:
> Why not bytes.viewbytes (or whatever name) so that one could also
> subscript it? And if it were a property, one could perhaps
> conveniently get the n'th byte:
>
> b'abcde'.viewbytes[n] # compared to b'abcde'[n:n+1]
AFAICT, 'viewbytes' doesn't add much over bytes itself if we add a 'getbyte' method.
> Also, would it not be more clear to call the int -> bytes method
> something like bytes.fromint or bytes.fromord and introduce the same
> thing on str? And perhaps allow multiple arguments to create a
> str/bytes of length > 1. I guess this may violate TOOWTDI, but anyway,
> just a thought.
Yes, it would. Changing to 'bytes.fromint'.
--
~Ethan~
More information about the Python-Dev
mailing list