[Python-checkins] cpython (2.7): Issue #29019: Fix dict.fromkeys(x) overallocates when x is sparce dict.
inada.naoki
python-checkins at python.org
Tue Dec 20 02:07:39 EST 2016
https://hg.python.org/cpython/rev/46e329ef13ae
changeset: 105758:46e329ef13ae
branch: 2.7
parent: 105754:0391b6875319
user: INADA Naoki <songofacandy at gmail.com>
date: Tue Dec 20 16:07:18 2016 +0900
summary:
Issue #29019: Fix dict.fromkeys(x) overallocates when x is sparce dict.
Original patch by Rasmus Villemoes.
files:
Misc/NEWS | 3 +++
Objects/dictobject.c | 2 +-
2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -13,6 +13,9 @@
Library
-------
+- Issue #29019: Fix dict.fromkeys(x) overallocates when x is sparce dict.
+ Original patch by Rasmus Villemoes.
+
- Issue #19542: Fix bugs in WeakValueDictionary.setdefault() and
WeakValueDictionary.pop() when a GC collection happens in another
thread.
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1391,7 +1391,7 @@
PyObject *key;
long hash;
- if (dictresize(mp, Py_SIZE(seq) / 2 * 3)) {
+ if (dictresize(mp, ((PyDictObject *)seq)->ma_used / 2 * 3)) {
Py_DECREF(d);
return NULL;
}
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list