Author inada.naoki
Recipients inada.naoki, vstinner
Date 2016-11-18.11:08:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1479467308.33.0.107267316387.issue28731@psf.upfronthosting.co.za>
In-reply-to
Content
This patch includes fix for ESTIMATE_SIZE macro. (see below)
Same fix is included in patch for issue28147.

>>> def estimate_size(n):
...     return n * 3 // 2  # Current ESTIMATE_SIZE
...
>>> def usable(n):
...     return n * 2 // 3
...
>>> def keysize(minsize):
...     size = 8
...     while size < minsize:  # Current implementation uses <=
...         size *= 2
...     return size
...
>>> def check():
...     for i in range(1000):
...         estimate = estimate_size(i)
...         size = keysize(estimate)
...         cap = usable(size)
...         if cap < i:
...             print(i, estimate, size, cap)
...
>>> check()
11 16 16 10
43 64 64 42
171 256 256 170
683 1024 1024 682
>>> # 
>>> estimate_size = lambda n: (n * 3 +1) // 2  # Fixed version
>>> check()
>>>
History
Date User Action Args
2016-11-18 11:08:28inada.naokisetrecipients: + inada.naoki, vstinner
2016-11-18 11:08:28inada.naokisetmessageid: <1479467308.33.0.107267316387.issue28731@psf.upfronthosting.co.za>
2016-11-18 11:08:28inada.naokilinkissue28731 messages
2016-11-18 11:08:27inada.naokicreate