Author inada.naoki
Recipients inada.naoki, serhiy.storchaka, vstinner
Date 2016-11-18.12:57:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1479473865.06.0.999811305772.issue28731@psf.upfronthosting.co.za>
In-reply-to
Content
Python 3.5 has similar issue:
$ ~/local/py35/bin/patched -m perf timeit --compare-to ~/local/py35/bin/master -- 'd = {"a":1, "b":2, "c":3, "d":4, "e":5, "f":6}'
master: ..................... 1.15 us +- 0.09 us
patched: ..................... 885 ns +- 37 ns

Median +- std dev: [master] 1.15 us +- 0.09 us -> [patched] 885 ns +- 37 ns: 1.30x faster


patch:
diff -r 20f62e4a9c2f Objects/dictobject.c
--- a/Objects/dictobject.c      Wed Nov 16 16:32:22 2016 -0800
+++ b/Objects/dictobject.c      Fri Nov 18 12:56:38 2016 +0000
@@ -1015,8 +1015,9 @@ PyObject *
 {
     Py_ssize_t newsize;
     PyDictKeysObject *new_keys;
+    minused = (minused * 3 + 1) / 2;
     for (newsize = PyDict_MINSIZE_COMBINED;
-         newsize <= minused && newsize > 0;
+         newsize < minused && newsize > 0;
          newsize <<= 1)
         ;
     new_keys = new_keys_object(newsize);
History
Date User Action Args
2016-11-18 12:57:45inada.naokisetrecipients: + inada.naoki, vstinner, serhiy.storchaka
2016-11-18 12:57:45inada.naokisetmessageid: <1479473865.06.0.999811305772.issue28731@psf.upfronthosting.co.za>
2016-11-18 12:57:45inada.naokilinkissue28731 messages
2016-11-18 12:57:44inada.naokicreate