Skip to content

Nested lock in set.issuperset #159486

Closed as not planned
Closed as not planned

Description

@johng

When calling set is set_issuperset_impl() is already locked but calls set_issubset which
just wraps a lock to set_issubset_impl

Fixing it is very minimal, there is already a non lock very of set_is_subset, leading to just under 2x speedup on macos on free-threading

$ ./python -m timeit -s "a = set('abcdefgh'); b = set('abcd')" "a >= b"
before: 10000000 loops, best of 5: 35.4 nsec per loop
after:  20000000 loops, best of 5: 18.5 nsec per loop

$ ./python -m timeit -s "a = set('abcdefgh'); b = set('abcd')" "a.issuperset(b)"
before: 10000000 loops, best of 5: 38.7 nsec per loop
after:  10000000 loops, best of 5: 20.2 nsec per loop

Linked PRs

Activity

  1. added
    type-feature
    performance
    interpreter-core
    and removed
    interpreter-core
    on Oct 15, 2026
  2. johng commented on Oct 16, 2026

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-coreperformancetopic-free-threadingtype-feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions