gh-112075: use per-thread dict version pool (#118676)

use thread state set of dict versions
This commit is contained in:
Dino Viehland 2024-05-06 17:22:26 -07:00 • committed by GitHub
parent 723d4d2fe8
commit ff6cbb2503
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 70 additions and 3 deletions

View file

@ -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},
};