[Python-Dev] s/bytes/octet/ [Was:Re: bytes.from_hex() [Was: PEP 332 revival in coordination with pep 349?]]

Ron Adam rrr at ronadam.com
Tue Feb 21 18:40:37 CET 2006


Greg Ewing wrote:
> Ron Adam wrote:
> 
>> Storing byte information as 16 or 32 bits ints could take up a rather 
>> lot of memory in some cases.
> 
> I don't quite see the point here. Inside a bytes object,
> they would be stored 1 byte per byte. Nobody is suggesting
> that they would take up more than that just because
> a_bytes_object[i] happens to return an int.

Yes, and the above is the obvious reason why not.  Not that I thought it 
was being considered.


> So the only reason to introduce a new "byte" type is to
> remove some of the operations that int has. We can already
> do bitwise operations on an int, so we don't need a new
> type to add that capability.

Yes, and a byte type isn't needed if the individual bytes are always in 
a bytes object. A bytes object with a single byte would be an octet in 
that case.

> What's more, I can see this leading to people asking for
> arithmetic operations to be *added* to the byte type so
> they can do wrap-around arithmetic, and then for 16-bit,
> 32-bit, 64-bit etc. versions of it, etc. etc.

I agree the bytes object shouldn't re implement arithmetic.  I would 
like bitwise logic operations on bytes() and byte ranges() if possible.

Cheers,
    Ronald Adam
















More information about the Python-Dev mailing list