diff -r 6b46c3deea2c Objects/dictobject.c --- a/Objects/dictobject.c Tue Oct 25 11:51:54 2016 -0700 +++ b/Objects/dictobject.c Wed Oct 26 04:03:13 2016 +0900 @@ -2403,15 +2403,17 @@ */ override = 1; /* Do one big resize at the start, rather than * incrementally resizing as we insert new items. Expect * that there will be no (or few) overlapping keys. */ - if (mp->ma_keys->dk_usable * 3 < other->ma_used * 2) - if (dictresize(mp, (mp->ma_used + other->ma_used)*2) != 0) + if (mp->ma_keys->dk_usable < other->ma_used) { + if (dictresize(mp, ESTIMATE_SIZE(mp->ma_used + other->ma_used))) { return -1; + } + } ep0 = DK_ENTRIES(other->ma_keys); for (i = 0, n = other->ma_keys->dk_nentries; i < n; i++) { PyObject *key, *value; Py_hash_t hash; entry = &ep0[i]; key = entry->me_key;