[issue20895] Add bytes.empty_buffer and deprecate bytes(17) for the same purpose

Ethan Furman report at bugs.python.org
Sat Mar 15 16:56:05 CET 2014


Ethan Furman added the comment:

Python 2.7.3 (default, Sep 26 2012, 21:51:14) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

--> bytes(5)
'5'

--> bytearray(5)
bytearray(b'\x00\x00\x00\x00\x00')
----------------------------------------------------------------------

Creating a buffer of null bytes makes sense for bytearray, which is mutable; it does not make sense, and IMHO only causes confusion, to have bytes return an /immutable/ sequence of zero bytes.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20895>
_______________________________________


More information about the Python-bugs-list mailing list