Skip to content

internal: use PySet_GET_SIZE for sets and frozensets#6226

Merged
Tpt merged 1 commit into
PyO3:mainfrom
charliermarsh:charlie/fast-python-set-length
Jul 23, 2026
Merged

internal: use PySet_GET_SIZE for sets and frozensets#6226
Tpt merged 1 commit into
PyO3:mainfrom
charliermarsh:charlie/fast-python-set-length

Conversation

@charliermarsh

Copy link
Copy Markdown
Contributor

See: #6225 (comment)

We can use PySet_GET_SIZE instead of PySet_Size when retrieving the length of Python sets and frozensets, matching the existing PyList fast path. Fall back to PySet_Size for limited-ABI builds, PyPy, and GraalPy.

@chirizxc

Copy link
Copy Markdown
Contributor

maybe it should be internal: ... (PR name)

@charliermarsh
charliermarsh marked this pull request as ready for review July 22, 2026 21:31
@charliermarsh charliermarsh changed the title Use PySet_GET_SIZE for sets and frozensets internal: use PySet_GET_SIZE for sets and frozensets Jul 22, 2026

@Tpt Tpt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Tpt
Tpt added this pull request to the merge queue Jul 23, 2026
Merged via the queue into PyO3:main with commit efa8b5d Jul 23, 2026
48 of 51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants