8000 dict: Remove redundant incref of immortal object Py_EMPTY_KEYS (GH-13… · python/cpython@0119791 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0119791

Browse files
authored
dict: Remove redundant incref of immortal object Py_EMPTY_KEYS (GH-133200)
1 parent cb35c11 commit 0119791

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Objects/dictobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4851,7 +4851,8 @@ dict_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
48514851

48524852
d->ma_used = 0;
48534853
d->_ma_watcher_tag = 0;
4854-
dictkeys_incref(Py_EMPTY_KEYS);
4854+
// We don't inc ref empty keys because they're immortal
4855+
assert((Py_EMPTY_KEYS)->dk_refcnt == _Py_DICT_IMMORTAL_INITIAL_REFCNT);
48554856
d->ma_keys = Py_EMPTY_KEYS;
48564857
d->ma_values = NULL;
48574858
ASSERT_CONSISTENT(d);

0 commit comments

Comments
 (0)
0