[Python-Dev] PEP 358 (bytes type) comments (original) (raw)

Bob Ippolito bob at redivi.com
Wed Feb 22 23:03:29 CET 2006


On Feb 22, 2006, at 1:22 PM, Brett Cannon wrote:

First off, thanks to Neil for writing this all down. The whole thread of discussion on the bytes type was rather long and thus hard to follow. Nice to finally have it written down in a PEP.

Anyway, a few comments on the PEP. One, should the hex() method instead be an attribute, implemented as a property? Seems like static data that is entirely based on the value of the bytes object and thus is not properly represented by a method. Next, why are the *slice methods to be defined? Docs say they are deprecated. And for the open-ended questions, I don't think sort() is needed.

sort would be totally useless for bytes. array.array doesn't have
sort either.

Lastly, maybe I am just dense, but it took me a second to realize that it will most likely return the ASCII string for str() for use in something like socket.send(), but it isn't explicitly stated anywhere. There is a chance someone might think that str will somehow return the sequence of integers as a string does exist.

That would be a bad idea given that bytes are supposed make the str
type go away. It's probably better to make str return repr
like it does for most types. If bytes type supports the buffer API
(one would hope so), functions like socket.send should do the right
thing as-is.

http://docs.python.org/api/bufferObjects.html

-bob



More information about the Python-Dev mailing list