diff options
author | Michael Droettboom <mdboom@gmail.com> | 2025-03-27 09:57:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-27 09:57:06 -0400 |
commit | 8614f86b7163b1c39798b481902dbb511292a537 (patch) | |
tree | 2bf6a46b432df3d6bf01a4176f3a614a01c48566 /Python/clinic/bltinmodule.c.h | |
parent | cf5e438c0297954c4411c1c3ae4ba67a48b134ea (diff) | |
download | cpython-8614f86b7163b1c39798b481902dbb511292a537.tar.gz cpython-8614f86b7163b1c39798b481902dbb511292a537.zip |
gh-131525: Cache the result of tuple_hash (#131529)
* gh-131525: Cache the result of tuple_hash
* Fix debug builds
* Add blurb
* Fix formatting
* Pre-compute empty tuple singleton
* Mostly set the cache within tuple_alloc
* Fixes for TSAN
* Pre-compute empty tuple singleton
* Fix for 32-bit platforms
* Assert that op != NULL in _PyTuple_RESET_HASH_CACHE
* Use FT_ATOMIC_STORE_SSIZE_RELAXED macro
* Update Include/internal/pycore_tuple.h
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* Fix alignment
* atomic load
* Update Objects/tupleobject.c
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
---------
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
Diffstat (limited to 'Python/clinic/bltinmodule.c.h')
-rw-r--r-- | Python/clinic/bltinmodule.c.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h index e5f634e34cb..c826a5724f7 100644 --- a/Python/clinic/bltinmodule.c.h +++ b/Python/clinic/bltinmodule.c.h @@ -46,9 +46,11 @@ builtin___import__(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD + Py_hash_t ob_hash; PyObject *ob_item[NUM_KEYWORDS]; } _kwtuple = { .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, .ob_item = { &_Py_ID(name), &_Py_ID(globals), &_Py_ID(locals), &_Py_ID(fromlist), &_Py_ID(level), }, }; #undef NUM_KEYWORDS @@ -270,9 +272,11 @@ builtin_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD + Py_hash_t ob_hash; PyObject *ob_item[NUM_KEYWORDS]; } _kwtuple = { .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, .ob_item = { &_Py_ID(source), &_Py_ID(filename), &_Py_ID(mode), &_Py_ID(flags), &_Py_ID(dont_inherit), &_Py_ID(optimize), &_Py_ID(_feature_version), }, }; #undef NUM_KEYWORDS @@ -425,9 +429,11 @@ builtin_eval(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD + Py_hash_t ob_hash; PyObject *ob_item[NUM_KEYWORDS]; } _kwtuple = { .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, .ob_item = { &_Py_ID(globals), &_Py_ID(locals), }, }; #undef NUM_KEYWORDS @@ -504,9 +510,11 @@ builtin_exec(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD + Py_hash_t ob_hash; PyObject *ob_item[NUM_KEYWORDS]; } _kwtuple = { .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, .ob_item = { &_Py_ID(globals), &_Py_ID(locals), &_Py_ID(closure), }, }; #undef NUM_KEYWORDS @@ -857,9 +865,11 @@ builtin_pow(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD + Py_hash_t ob_hash; PyObject *ob_item[NUM_KEYWORDS]; } _kwtuple = { .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, .ob_item = { &_Py_ID(base), &_Py_ID(exp), &_Py_ID(mod), }, }; #undef NUM_KEYWORDS @@ -933,9 +943,11 @@ builtin_print(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD + Py_hash_t ob_hash; PyObject *ob_item[NUM_KEYWORDS]; } _kwtuple = { .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, .ob_item = { &_Py_ID(sep), &_Py_ID(end), &_Py_ID(file), &_Py_ID(flush), }, }; #undef NUM_KEYWORDS @@ -1075,9 +1087,11 @@ builtin_round(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD + Py_hash_t ob_hash; PyObject *ob_item[NUM_KEYWORDS]; } _kwtuple = { .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, .ob_item = { &_Py_ID(number), &_Py_ID(ndigits), }, }; #undef NUM_KEYWORDS @@ -1142,9 +1156,11 @@ builtin_sum(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD + Py_hash_t ob_hash; PyObject *ob_item[NUM_KEYWORDS]; } _kwtuple = { .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, .ob_item = { &_Py_ID(start), }, }; #undef NUM_KEYWORDS @@ -1252,4 +1268,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=c08e0e086a791ff0 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e7a5d0851d7f2cfb input=a9049054013a1b77]*/ |