diff -r 2d072d07dfe2 Modules/_functoolsmodule.c --- a/Modules/_functoolsmodule.c Sun Jun 21 14:43:15 2015 +0300 +++ b/Modules/_functoolsmodule.c Sun Jun 21 15:14:38 2015 +0300 @@ -813,11 +813,15 @@ bounded_lru_cache_wrapper(lru_cache_obje { lru_list_elem *link; PyObject *key, *result; + Py_hash_t hash; key = lru_cache_make_key(args, kwds, self->typed); if (!key) return NULL; - link = (lru_list_elem *)PyDict_GetItemWithError(self->cache, key); + hash = PyObject_Hash(key); + if (hash == -1) + return NULL; + link = (lru_list_elem *)_PyDict_GetItem_KnownHash(self->cache, key, hash); if (link) { lru_cache_extricate_link(link); lru_cache_append_link(self, link); @@ -861,7 +865,8 @@ bounded_lru_cache_wrapper(lru_cache_obje link->key = key; link->result = result; - if (PyDict_SetItem(self->cache, key, (PyObject *)link) < 0) { + if (_PyDict_SetItem_KnownHash(self->cache, key, (PyObject *)link, + hash) < 0) { Py_DECREF(link); Py_DECREF(oldkey); Py_DECREF(oldresult); @@ -884,7 +889,8 @@ bounded_lru_cache_wrapper(lru_cache_obje link->key = key; link->result = result; _PyObject_GC_TRACK(link); - if (PyDict_SetItem(self->cache, key, (PyObject *)link) < 0) { + if (_PyDict_SetItem_KnownHash(self->cache, key, (PyObject *)link, + hash) < 0) { Py_DECREF(link); return NULL; }