]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Optimize bytearray % args
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 14 Oct 2015 07:56:53 +0000 (09:56 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 14 Oct 2015 07:56:53 +0000 (09:56 +0200)
commit772b2b09f279fdcb01bbd703735d35bd02dd8ec1
tree06c585be7db2c586bb8e2a09c2e74a8b2188e841
parent661aaccf9def380540cc1d440761159a414094d1
Optimize bytearray % args

Issue #25399: Don't create temporary bytes objects: modify _PyBytes_Format() to
create work directly on bytearray objects.

* Rename _PyBytes_Format() to _PyBytes_FormatEx() just in case if something
  outside CPython uses it
* _PyBytes_FormatEx() now uses (char*, Py_ssize_t) for the input string, so
  bytearray_format() doesn't need tot create a temporary input bytes object
* Add use_bytearray parameter to _PyBytes_FormatEx() which is passed to
  _PyBytesWriter, to create a bytearray buffer instead of a bytes buffer

Most formatting operations are now between 2.5 and 5 times faster.
Include/bytesobject.h
Objects/bytearrayobject.c
Objects/bytesobject.c