https://github.com/python/cpython/commit/011979132648d50f83d4506d768dca24de47c8c6 commit: 011979132648d50f83d4506d768dca24de47c8c6 branch: main author: Mae Hood <22501070+bigliza...@users.noreply.github.com> committer: methane <songofaca...@gmail.com> date: 2025-05-01T08:39:26+09:00 summary:
dict: Remove redundant incref of immortal object Py_EMPTY_KEYS (GH-133200) files: M Objects/dictobject.c diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 00658a8ac35bcf..59b0cf1ce7d422 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -4851,7 +4851,8 @@ dict_new(PyTypeObject *type, PyObject *args, PyObject *kwds) d->ma_used = 0; d->_ma_watcher_tag = 0; - dictkeys_incref(Py_EMPTY_KEYS); + // We don't inc ref empty keys because they're immortal + assert((Py_EMPTY_KEYS)->dk_refcnt == _Py_DICT_IMMORTAL_INITIAL_REFCNT); d->ma_keys = Py_EMPTY_KEYS; d->ma_values = NULL; ASSERT_CONSISTENT(d); _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com