@@ -9,6 +9,9 @@ extern "C" {
99# error "this header requires Py_BUILD_CORE define"
1010#endif
1111
12+ #include "pycore_dict_state.h"
13+ #include "pycore_runtime.h" // _PyRuntime
14+
1215
1316/* runtime lifecycle */
1417
@@ -17,25 +20,6 @@ extern void _PyDict_Fini(PyInterpreterState *interp);
1720
1821/* other API */
1922
20- #ifndef WITH_FREELISTS
21- // without freelists
22- # define PyDict_MAXFREELIST 0
23- #endif
24-
25- #ifndef PyDict_MAXFREELIST
26- # define PyDict_MAXFREELIST 80
27- #endif
28-
29- struct _Py_dict_state {
30- #if PyDict_MAXFREELIST > 0
31- /* Dictionary reuse scheme to save calls to malloc and free */
32- PyDictObject * free_list [PyDict_MAXFREELIST ];
33- int numfree ;
34- PyDictKeysObject * keys_free_list [PyDict_MAXFREELIST ];
35- int keys_numfree ;
36- #endif
37- };
38-
3923typedef struct {
4024 /* Cached hash code of me_key. */
4125 Py_hash_t me_hash ;
@@ -152,13 +136,11 @@ struct _dictvalues {
152136 (PyDictUnicodeEntry*)(&((int8_t*)((dk)->dk_indices))[(size_t)1 << (dk)->dk_log2_index_bytes]))
153137#define DK_IS_UNICODE (dk ) ((dk)->dk_kind != DICT_KEYS_GENERAL)
154138
155- extern uint64_t _pydict_global_version ;
156-
157- #define DICT_MAX_WATCHERS 8
158139#define DICT_VERSION_INCREMENT (1 << DICT_MAX_WATCHERS)
159140#define DICT_VERSION_MASK (DICT_VERSION_INCREMENT - 1)
160141
161- #define DICT_NEXT_VERSION () (_pydict_global_version += DICT_VERSION_INCREMENT)
142+ #define DICT_NEXT_VERSION () \
143+ (_PyRuntime.dict_state.global_version += DICT_VERSION_INCREMENT)
162144
163145void
164146_PyDict_SendEvent (int watcher_bits ,
0 commit comments