summaryrefslogtreecommitdiffstats
path: root/Include/internal/pycore_dict.h
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2022-11-16 17:37:29 (GMT)
committerGitHub <noreply@github.com>2022-11-16 17:37:29 (GMT)
commit9db1e17c80217d7b18a2f44297d72acd10ee73d6 (patch)
tree4d0256b80f512133b1fb6db73a68da5bdbe22c5c /Include/internal/pycore_dict.h
parent8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b (diff)
downloadcpython-9db1e17c80217d7b18a2f44297d72acd10ee73d6.zip
cpython-9db1e17c80217d7b18a2f44297d72acd10ee73d6.tar.gz
cpython-9db1e17c80217d7b18a2f44297d72acd10ee73d6.tar.bz2
gh-81057: Move the global Dict-Related Versions to _PyRuntimeState (gh-99497)
We also move the global func version. https://github.com/python/cpython/issues/81057
Diffstat (limited to 'Include/internal/pycore_dict.h')
-rw-r--r--Include/internal/pycore_dict.h28
1 files changed, 5 insertions, 23 deletions
diff --git a/Include/internal/pycore_dict.h b/Include/internal/pycore_dict.h
index ae4094a..25bd3bf 100644
--- a/Include/internal/pycore_dict.h
+++ b/Include/internal/pycore_dict.h
@@ -9,6 +9,9 @@ extern "C" {
# error "this header requires Py_BUILD_CORE define"
#endif
+#include "pycore_dict_state.h"
+#include "pycore_runtime.h" // _PyRuntime
+
/* runtime lifecycle */
@@ -17,25 +20,6 @@ extern void _PyDict_Fini(PyInterpreterState *interp);
/* other API */
-#ifndef WITH_FREELISTS
-// without freelists
-# define PyDict_MAXFREELIST 0
-#endif
-
-#ifndef PyDict_MAXFREELIST
-# define PyDict_MAXFREELIST 80
-#endif
-
-struct _Py_dict_state {
-#if PyDict_MAXFREELIST > 0
- /* Dictionary reuse scheme to save calls to malloc and free */
- PyDictObject *free_list[PyDict_MAXFREELIST];
- int numfree;
- PyDictKeysObject *keys_free_list[PyDict_MAXFREELIST];
- int keys_numfree;
-#endif
-};
-
typedef struct {
/* Cached hash code of me_key. */
Py_hash_t me_hash;
@@ -152,13 +136,11 @@ struct _dictvalues {
(PyDictUnicodeEntry*)(&((int8_t*)((dk)->dk_indices))[(size_t)1 << (dk)->dk_log2_index_bytes]))
#define DK_IS_UNICODE(dk) ((dk)->dk_kind != DICT_KEYS_GENERAL)
-extern uint64_t _pydict_global_version;
-
-#define DICT_MAX_WATCHERS 8
#define DICT_VERSION_INCREMENT (1 << DICT_MAX_WATCHERS)
#define DICT_VERSION_MASK (DICT_VERSION_INCREMENT - 1)
-#define DICT_NEXT_VERSION() (_pydict_global_version += DICT_VERSION_INCREMENT)
+#define DICT_NEXT_VERSION() \
+ (_PyRuntime.dict_state.global_version += DICT_VERSION_INCREMENT)
void
_PyDict_SendEvent(int watcher_bits,