Kaydet (Commit) 77b3ae5e authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Issue #23971: Fix underestimated presizing in dict.fromkeys()

üst bd049190
...@@ -25,6 +25,8 @@ Core and Builtins ...@@ -25,6 +25,8 @@ Core and Builtins
- Issue #20274: When calling a _sqlite.Connection, it now complains if passed - Issue #20274: When calling a _sqlite.Connection, it now complains if passed
any keyword arguments. Previously it silently ignored them. 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 - Issue #20274: Remove ignored and erroneous "kwargs" parameters from three
METH_VARARGS methods on _sqlite.Connection. METH_VARARGS methods on _sqlite.Connection.
......
...@@ -1361,7 +1361,7 @@ dict_fromkeys(PyObject *cls, PyObject *args) ...@@ -1361,7 +1361,7 @@ dict_fromkeys(PyObject *cls, PyObject *args)
PyObject *key; PyObject *key;
long hash; long hash;
if (dictresize(mp, Py_SIZE(seq))) { if (dictresize(mp, Py_SIZE(seq) / 2 * 3)) {
Py_DECREF(d); Py_DECREF(d);
return NULL; return NULL;
} }
...@@ -1382,7 +1382,7 @@ dict_fromkeys(PyObject *cls, PyObject *args) ...@@ -1382,7 +1382,7 @@ dict_fromkeys(PyObject *cls, PyObject *args)
PyObject *key; PyObject *key;
long hash; long hash;
if (dictresize(mp, PySet_GET_SIZE(seq))) { if (dictresize(mp, PySet_GET_SIZE(seq) / 2 * 3)) {
Py_DECREF(d); Py_DECREF(d);
return NULL; return NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment