]> granicus.if.org Git - python/commit
Issue #25349: Optimize bytes % args using the new private _PyBytesWriter API
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 9 Oct 2015 09:48:06 +0000 (11:48 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 9 Oct 2015 09:48:06 +0000 (11:48 +0200)
commitfa7762ec066aa3632a25b6a52bb7597b8f17c2f3
tree9f14bcc1d8c0f316c5e9f5dcc549686fff42340b
parentbd5f0e8c1cf633a238c10e1d3199c0d572a4df1d
Issue #25349: Optimize bytes % args using the new private _PyBytesWriter API

* Thanks to the _PyBytesWriter API, output smaller than 512 bytes are allocated
  on the stack and so avoid calling _PyBytes_Resize(). Because of that, change
  the default buffer size to fmtcnt instead of fmtcnt+100.
* Rely on _PyBytesWriter algorithm to overallocate the buffer instead of using
  a custom code. For example, _PyBytesWriter uses a different overallocation
  factor (25% or 50%) depending on the platform to get best performances.
* Disable overallocation for the last write.
* Replace C loops to fill characters with memset()
* Add also many comments to _PyBytes_Format()
* Remove unused FORMATBUFLEN constant
* Avoid the creation of a temporary bytes object when formatting a floating
  point number (when no custom formatting option is used)
* Fix also reference leaks on error handling
* Use Py_MEMCPY() to copy bytes between two formatters (%)
Misc/NEWS
Objects/bytesobject.c