Byte oriented data types in python

"Martin v. Löwis" martin at v.loewis.de
Sun Jan 25 16:21:08 EST 2009


> Looks to me like there was already a reasonable way of getting a bytes
> object containing a variable number of zero bytes. Any particular
> reason why bytes(n) was given this specialised meaning?

I think it was because bytes() was originally mutable, and you need a
way to create a buffer of n bytes. Now that bytes() ended up immutable
(and bytearray was added), it's perhaps not so useful anymore. Of
course, it would be confusing if bytes(4) created a sequence of one
byte, yet bytearray(4) created four bytes.

Regards,
Martin



More information about the Python-list mailing list