FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-112069: Make sets thread-safe with the GIL disabled by tomasr8 · Pull Request #113800 · python/cpython · GitHub

/ cpython Public

gh-112069: Make sets thread-safe with the GIL disabled - #113800

Merged
colesbury merged 28 commits into
python:mainfrom
tomasr8:gil-set
Mar 8, 2024
Merged

gh-112069: Make sets thread-safe with the GIL disabled#113800
colesbury merged 28 commits into
python:mainfrom
tomasr8:gil-set

Conversation

tomasr8 commented Jan 7, 2024
edited by corona10
Loading

Copy link
Copy Markdown
Member

Still have some failing tests in the GIL version so marking as a draft for now until I manage to fix them.
This PR is mostly based on Sam's version: colesbury/nogil-3.12@4ca2924f0d

Since sets have a lot of methods that are exposed, I made this list to keep track and help with the review:

set methods

Method Thread-safe (comments)
set_add
set_clear
set.__contains__
set_copy
set_discard
set_difference_multi
set_difference_update
set_intersection_multi
set_intersection_update_multi
set_isdisjoint
set_issubset
set_issuperset
set_pop
set.__reduce__
set_remove
set.__sizeof__
set_symmetric_difference
set_symmetric_difference_update
set_union
set_update

set_as_number

Method Thread-safe (comments)
set_sub
set_and
set_xor ✅ (via set_symmetric_difference)
set_or
set_isub
set_iand
set_ixor
set_ior

set tp_..

Method Thread-safe (comments)
set_dealloc Not needed
set_repr
set_as_sequence(set_len, set_contains)
set_traverse Not needed
set_clear_internal Not needed
set_richcompare ❌ (will be done separately)
set_iter
set_init
set_new
set_vectorcall

There are also some extra frozenset methods which I don't think need locking: frozenset_copy, frozenset_hash, frozenset_new, frozenset_vectorcall. The rest of frozenset methods are shared with sets.

C API methods:

Method Thread-safe (comments)
PySet_New
PyFrozenSet_New
PySet_Size ✅ (via set_len)
PySet_Clear ✅ (via set_clear)
PySet_Contains
PySet_Discard
PySet_Add
_PySet_NextEntry
PySet_Pop ✅ (via set_pop)
_PySet_Update

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants


Back | FazBrowse Home | New Git URL