mirror of
https://github.com/python/cpython.git
synced 2025-12-04 16:43:27 +00:00
Issue #16562: Optimize dict equality testing.
Patch by Serhiy Storchaka (reviewed by Martin and Raymond).
This commit is contained in:
parent
181e20a6fc
commit
0e9958b543
2 changed files with 8 additions and 1 deletions
|
|
@ -10,6 +10,8 @@ What's New in Python 3.4.0 Alpha 1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #16562: Optimize dict equality testing. Patch by Serhiy Storchaka.
|
||||||
|
|
||||||
- Issue #16588: Silence unused-but-set warnings in Python/thread_pthread
|
- Issue #16588: Silence unused-but-set warnings in Python/thread_pthread
|
||||||
|
|
||||||
- Issue #16592: stringlib_bytes_join doesn't raise MemoryError on allocation
|
- Issue #16592: stringlib_bytes_join doesn't raise MemoryError on allocation
|
||||||
|
|
|
||||||
|
|
@ -2114,13 +2114,18 @@ dict_equal(PyDictObject *a, PyDictObject *b)
|
||||||
if (aval != NULL) {
|
if (aval != NULL) {
|
||||||
int cmp;
|
int cmp;
|
||||||
PyObject *bval;
|
PyObject *bval;
|
||||||
|
PyObject **vaddr;
|
||||||
PyObject *key = ep->me_key;
|
PyObject *key = ep->me_key;
|
||||||
/* temporarily bump aval's refcount to ensure it stays
|
/* temporarily bump aval's refcount to ensure it stays
|
||||||
alive until we're done with it */
|
alive until we're done with it */
|
||||||
Py_INCREF(aval);
|
Py_INCREF(aval);
|
||||||
/* ditto for key */
|
/* ditto for key */
|
||||||
Py_INCREF(key);
|
Py_INCREF(key);
|
||||||
bval = PyDict_GetItemWithError((PyObject *)b, key);
|
/* reuse the known hash value */
|
||||||
|
if ((b->ma_keys->dk_lookup)(b, key, ep->me_hash, &vaddr) == NULL)
|
||||||
|
bval = NULL;
|
||||||
|
else
|
||||||
|
bval = *vaddr;
|
||||||
Py_DECREF(key);
|
Py_DECREF(key);
|
||||||
if (bval == NULL) {
|
if (bval == NULL) {
|
||||||
Py_DECREF(aval);
|
Py_DECREF(aval);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue