diff options
author | Dino Viehland <dinoviehland@meta.com> | 2024-01-25 17:34:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-25 17:34:03 (GMT) |
commit | 4850410b60183dac021ded219a49be140fe5fefe (patch) | |
tree | 4487d9e47b04e4dbde2fa33c8d6980466f62574f /Lib/threading.py | |
parent | 8278fa2f5625b41be91191d18ee8eeab904a54ff (diff) | |
download | cpython-4850410b60183dac021ded219a49be140fe5fefe.zip cpython-4850410b60183dac021ded219a49be140fe5fefe.tar.gz cpython-4850410b60183dac021ded219a49be140fe5fefe.tar.bz2 |
gh-112075: Add try-incref functions from nogil branch for use in dict thread safety (#114512)
* Bring in a subset of biased reference counting:
https://github.com/colesbury/nogil/commit/b6b12a9a94e
The NoGIL branch has functions for attempting to do an incref on an object which may or may not be in flight. This just brings those functions over so that they will be usable from in the dict implementation to get items w/o holding a lock.
There's a handful of small simple modifications:
Adding inline to the force inline functions to avoid a warning, and switching from _Py_ALWAYS_INLINE to Py_ALWAYS_INLINE as that's available
Remove _Py_REF_LOCAL_SHIFT as it doesn't exist yet (and is currently 0 in the 3.12 nogil branch anyway)
ob_ref_shared is currently Py_ssize_t and not uint32_t, so use that
_PY_LIKELY doesn't exist, so drop it
_Py_ThreadLocal becomes _Py_IsOwnedByCurrentThread
Add '_PyInterpreterState_GET()' to _Py_IncRefTotal calls.
Co-Authored-By: Sam Gross <colesbury@gmail.com>
Diffstat (limited to 'Lib/threading.py')
0 files changed, 0 insertions, 0 deletions