]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #23971: Fix underestimated presizing in dict.fromkeys()
authorRaymond Hettinger <python@rcn.com>
Wed, 13 May 2015 10:13:28 +0000 (03:13 -0700)
committerRaymond Hettinger <python@rcn.com>
Wed, 13 May 2015 10:13:28 +0000 (03:13 -0700)
Misc/NEWS
Objects/dictobject.c

index 39de4205de69b0a98d3ee3900e98741f1814c7e0..bd20dba2fa09f35296d34360bac859e6fbc980ec 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -25,6 +25,8 @@ Core and Builtins
 - Issue #20274: When calling a _sqlite.Connection, it now complains if passed
   any keyword arguments.  Previously it silently ignored them.
 
+- Issue #23971:  Fix underestimated presizing in dict.fromkeys().
+
 - Issue #20274: Remove ignored and erroneous "kwargs" parameters from three
   METH_VARARGS methods on _sqlite.Connection.
 
index 39e7035901033985706cffb243f5440d77fb3645..50afa3f654a85a808a95b8bb7b2bbc58bd0d0c7c 100644 (file)
@@ -1361,7 +1361,7 @@ dict_fromkeys(PyObject *cls, PyObject *args)
             PyObject *key;
             long hash;
 
-            if (dictresize(mp, Py_SIZE(seq))) {
+            if (dictresize(mp, Py_SIZE(seq) / 2 * 3)) {
                 Py_DECREF(d);
                 return NULL;
             }
@@ -1382,7 +1382,7 @@ dict_fromkeys(PyObject *cls, PyObject *args)
             PyObject *key;
             long hash;
 
-            if (dictresize(mp, PySet_GET_SIZE(seq))) {
+            if (dictresize(mp, PySet_GET_SIZE(seq) / 2 * 3)) {
                 Py_DECREF(d);
                 return NULL;
             }