mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
gh-112075: use per-thread dict version pool (#118676)
use thread state set of dict versions
This commit is contained in:
parent
723d4d2fe8
commit
ff6cbb2503
5 changed files with 70 additions and 3 deletions
|
|
@ -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},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue