Skip to content

Conversation

@colesbury
Copy link
Contributor

@colesbury colesbury commented Dec 17, 2025

Now that we specialize range iteration in the interpreter, there's not a significant performance cost to making the iteration thread-safe.

Now that we specialize range iteration in the interpreter for the common
case where the iterator has only one reference, there's not a
significant performance cost to making the iteration thread-safe.
@colesbury
Copy link
Contributor Author

https://github.com/facebookexperimental/free-threading-benchmarking/tree/main/results/bm-20251216-3.15.0a3+-afd3eff-CLANG,NOGIL shows 1.001x faster, which I think is just noise.

I also ran https://github.com/colesbury/fastbench/ locally:

  • No measurable difference in performance
  • rangeiter_next is hit 40,000 times.
  • Some of those are pre-specialization. Most of them are fromlist.extend(range(...)).
  • At ~10 ns overhead per critical section and 13.1 seconds benchmark run time, that's about 0.003% extra overhead

FWIW, I used Codex to convert rangeobject.c to Argument Clinic and it worked pretty well.

Copy link
Contributor

@kumaraditya303 kumaraditya303 left a comment

Choose a reason for hiding this comment

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

LGTM

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.

2 participants