[Checkins] [zopefoundation/zope.server] 672787: Implement OverflowableBuffer in terms of SpooledTe...
GitHub
noreply at github.com
Fri Oct 27 22:57:12 CEST 2017
Branch: refs/heads/issue5
Home: https://github.com/zopefoundation/zope.server
Commit: 672787ebcac84ebab226129edc4b5437baa69dde
https://github.com/zopefoundation/zope.server/commit/672787ebcac84ebab226129edc4b5437baa69dde
Author: Jason Madden <jamadden at gmail.com>
Date: 2017-10-27 (Fri, 27 Oct 2017)
Changed paths:
M CHANGES.rst
M src/zope/server/buffers.py
M src/zope/server/tests/test_buffers.py
Log Message:
-----------
Implement OverflowableBuffer in terms of SpooledTemporaryFile
Fixes #5
Even for small buffers (the 8192 that previously were guaranteed to be
kept in a simple string) this should be faster, depending on the
number of writes possibly. Previously the strbuf was built up with
concatenation: `buf = buf + data`. Now we go directly into BytesIO and
avoid the extra copying.
Microbenchmarks on Python 3.6:
In [1]: def append():
...: buf = b''
...: while len(buf) < 8192:
...: buf += b'data' * 100
...:
In [4]: %timeit append()
10.9 µs ± 268 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In [8]: def bio():
...: b = io.BytesIO()
...: cnt = 0
...: while cnt < 8192:
...: cnt += b.write(b'data'*100)
...:
In [9]: bio()
In [10]: %timeit bio()
8.55 µs ± 282 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
More information about the checkins
mailing list