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

This commit is contained in:
Raymond Hettinger 2015-05-13 03:13:28 -07:00
parent bd04919014
commit 77b3ae5e2c
2 changed files with 4 additions and 2 deletions

View File

@ -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.

View 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;
}