summaryrefslogtreecommitdiffstats
path: root/Include/internal/pycore_weakref.h
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-118789: Add `PyUnstable_Object_ClearWeakRefsNoCallbacks` ↵Miss Islington (bot)2024-06-181-1/+1
| | | | | | | | | | | | | | | | | (GH-118807) (#120695) This exposes `PyUnstable_Object_ClearWeakRefsNoCallbacks` as an unstable C-API function to provide a thread-safe mechanism for clearing weakrefs without executing callbacks. Some C-API extensions need to clear weakrefs without calling callbacks, such as after running finalizers like we do in subtype_dealloc. Previously they could use `_PyWeakref_ClearRef` on each weakref, but that's not thread-safe in the free-threaded build. (cherry picked from commit e8752d7b80775ec2a348cd4bf38cbe26a4a07615) Co-authored-by: Sam Gross <colesbury@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* [3.13] gh-118789: Restore hidden `_PyWeakref_ClearRef` (GH-118797) (GH-118903)Miss Islington (bot)2024-05-101-2/+0
| | | | | | | | | | | | | | | gh-118789: Restore hidden `_PyWeakref_ClearRef` (GH-118797) _PyWeakref_ClearRef was previously exposed in the public C-API, although it begins with an underscore and is not documented. It's used by a few C-API extensions. There is currently no alternative public API that can replace its use. _PyWeakref_ClearWeakRefsExceptCallbacks is the only thread-safe way to use _PyWeakref_ClearRef in the free-threaded build. This exposes the C symbol, but does not make the API public. (cherry picked from commit db5af7da092409030c9fbe0a3a986bd0ee441b8b) Co-authored-by: Sam Gross <colesbury@gmail.com>
* gh-111926: Make weakrefs thread-safe in free-threaded builds (#117168)mpage2024-04-081-17/+56
| | | | | | | | | Most mutable data is protected by a striped lock that is keyed on the referenced object's address. The weakref's hash is protected using the weakref's per-object lock. Note that this only affects free-threaded builds. Apart from some minor refactoring, the added code is all either gated by `ifdef`s or is a no-op (e.g. `Py_BEGIN_CRITICAL_SECTION`).
* gh-111926: Set up basic sementics of weakref API for freethreading (gh-113621)Donghee Na2024-01-031-19/+37
| | | | | --------- Co-authored-by: Sam Gross <colesbury@gmail.com>
* gh-111926: Update _PyWeakref_IS_DEAD to be thread-safe (gh-112267)Donghee Na2023-11-191-4/+11
|
* gh-105927: Remove _PyWeakref_GetWeakrefCount() (#106007)Victor Stinner2023-06-231-0/+4
| | | | | | Remove _PyWeakref_GetWeakrefCount() and _PyWeakref_ClearRef() from the public C API: move them to the internal C API. Refactor also _weakref_getweakrefs() code to make it more readable.
* gh-105927: Add _PyWeakref_IS_DEAD() function (#105992)Victor Stinner2023-06-221-0/+13
| | | | | | | | * Add _PyWeakref_IS_DEAD() internal function. * Modify is_dead_weakref() of Modules/_weakref.c and _pysqlite_drop_unused_cursor_references() to replace PyWeakref_GET_OBJECT() with _PyWeakref_IS_DEAD(). * Replace "int i" with "Py_ssize_t i" to iterate on cursors in _pysqlite_drop_unused_cursor_references().
* gh-105927: Add _PyWeakref_GET_REF() internal function (#105929)Victor Stinner2023-06-201-0/+40
Add new pycore_weakref.h internal header file.