diff options
author | Dino Viehland <dinoviehland@meta.com> | 2024-05-07 00:22:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-07 00:22:26 (GMT) |
commit | ff6cbb2503a8fe3fceeadd889e34fc9a8f308ecd (patch) | |
tree | ed2ab05ad2ca3f3819babe399933ffcb85c93ad4 /Modules/_testcapi | |
parent | 723d4d2fe8e77b398f0ccffcfa541149caaac6a1 (diff) | |
download | cpython-ff6cbb2503a8fe3fceeadd889e34fc9a8f308ecd.zip cpython-ff6cbb2503a8fe3fceeadd889e34fc9a8f308ecd.tar.gz cpython-ff6cbb2503a8fe3fceeadd889e34fc9a8f308ecd.tar.bz2 |
gh-112075: use per-thread dict version pool (#118676)
use thread state set of dict versions
Diffstat (limited to 'Modules/_testcapi')
-rw-r--r-- | Modules/_testcapi/dict.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Modules/_testcapi/dict.c b/Modules/_testcapi/dict.c index 4319906..e80d898 100644 --- a/Modules/_testcapi/dict.c +++ b/Modules/_testcapi/dict.c @@ -1,7 +1,6 @@ #include "parts.h" #include "util.h" - static PyObject * dict_containsstring(PyObject *self, PyObject *args) { @@ -182,6 +181,18 @@ dict_popstring_null(PyObject *self, PyObject *args) RETURN_INT(PyDict_PopString(dict, key, NULL)); } +static PyObject * +dict_version(PyObject *self, PyObject *dict) +{ + if (!PyDict_Check(dict)) { + PyErr_SetString(PyExc_TypeError, "expected dict"); + return NULL; + } +_Py_COMP_DIAG_PUSH +_Py_COMP_DIAG_IGNORE_DEPR_DECLS + return PyLong_FromUnsignedLongLong(((PyDictObject *)dict)->ma_version_tag); +_Py_COMP_DIAG_POP +} static PyMethodDef test_methods[] = { {"dict_containsstring", dict_containsstring, METH_VARARGS}, @@ -193,6 +204,7 @@ static PyMethodDef test_methods[] = { {"dict_pop_null", dict_pop_null, METH_VARARGS}, {"dict_popstring", dict_popstring, METH_VARARGS}, {"dict_popstring_null", dict_popstring_null, METH_VARARGS}, + {"dict_version", dict_version, METH_O}, {NULL}, }; |