[Python-Dev] PEP 467: Minor API improvements for bytes & bytearray

Victor Stinner victor.stinner at gmail.com
Fri Aug 15 21:59:40 CEST 2014


2014-08-15 21:54 GMT+02:00 Serhiy Storchaka <storchaka at gmail.com>:
> 15.08.14 08:50, Nick Coghlan написав(ла):
>> * add bytes.zeros() and bytearray.zeros() as a replacement
>
> b'\0' * n and bytearray(b'\0') * n look good replacements to me. No need to
> learn new method. And it works right now.

FYI there is a pending patch for bytearray(int) to use calloc()
instead of malloc(). It's faster for buffer for n larger than 1 MB:
http://bugs.python.org/issue21644

I'm not sure that the optimization is really useful.

Victor


More information about the Python-Dev mailing list