File tree Expand file tree Collapse file tree 5 files changed +11
-5
lines changed Expand file tree Collapse file tree 5 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ extern void _PyDict_Fini(PyInterpreterState *interp);
1717
1818/* other API */
1919
20+ struct _Py_dict_runtime_state {
21+ uint32_t next_keys_version ;
22+ };
23+
2024#ifndef WITH_FREELISTS
2125// without freelists
2226# define PyDict_MAXFREELIST 0
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ extern "C" {
99#endif
1010
1111#include "pycore_atomic.h" /* _Py_atomic_address */
12+ #include "pycore_dict.h" // struct _Py_dict_runtime_state
1213#include "pycore_gil.h" // struct _gil_runtime_state
1314#include "pycore_global_objects.h" // struct _Py_global_objects
1415#include "pycore_import.h" // struct _import_runtime_state
@@ -135,6 +136,7 @@ typedef struct pyruntimestate {
135136 _Py_AuditHookEntry * audit_hook_head ;
136137
137138 struct _Py_unicode_runtime_ids unicode_ids ;
139+ struct _Py_dict_runtime_state dict_state ;
138140
139141 struct {
140142 /* Used to set PyTypeObject.tp_version_tag */
Original file line number Diff line number Diff line change @@ -36,6 +36,9 @@ extern "C" {
3636 until _PyInterpreterState_Enable() is called. */ \
3737 .next_id = -1, \
3838 }, \
39+ .dict_state = { \
40+ .next_keys_version = 2, \
41+ }, \
3942 .types = { \
4043 .next_version_tag = 1, \
4144 }, \
Original file line number Diff line number Diff line change @@ -5661,17 +5661,15 @@ _PyDictKeys_DecRef(PyDictKeysObject *keys)
56615661 dictkeys_decref (keys );
56625662}
56635663
5664- static uint32_t next_dict_keys_version = 2 ;
5665-
56665664uint32_t _PyDictKeys_GetVersionForCurrentState (PyDictKeysObject * dictkeys )
56675665{
56685666 if (dictkeys -> dk_version != 0 ) {
56695667 return dictkeys -> dk_version ;
56705668 }
5671- if (next_dict_keys_version == 0 ) {
5669+ if (_PyRuntime . dict_state . next_keys_version == 0 ) {
56725670 return 0 ;
56735671 }
5674- uint32_t v = next_dict_keys_version ++ ;
5672+ uint32_t v = _PyRuntime . dict_state . next_keys_version ++ ;
56755673 dictkeys -> dk_version = v ;
56765674 return v ;
56775675}
Original file line number Diff line number Diff line change @@ -417,7 +417,6 @@ Python/getargs.c - static_arg_parsers -
417417
418418# other
419419Objects/dictobject.c - _pydict_global_version -
420- Objects/dictobject.c - next_dict_keys_version -
421420Objects/funcobject.c - next_func_version -
422421Objects/object.c - _Py_RefTotal -
423422Python/perf_trampoline.c - perf_status -
You can’t perform that action at this time.
0 commit comments