-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
gh-129068: allow concurrent iteration over range iterators #131921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tom-pytel
wants to merge
11
commits into
python:main
Choose a base branch
from
tom-pytel:fix-issue-129068
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+420
−285
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ping @colesbury, @Yhg1s. Sorry to bug you guys with two PRs this weekend. Please consider this one an experiment and let me know if it is worth continuing with, and if so what would need to be changed? |
…seTuple() (pythonGH-128374) Non-tuple sequences are deprecated as argument for the "(items)" format unit in PyArg_ParseTuple() and other argument parsing functions if items contains format units which store borrowed buffer or reference (e.g. "s" and "O"). str and bytearray are no longer accepted as valid sequences.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before anything, I'm not very familiar with the jit system so what I did to the ITER_RANGE micro-ops is maybe not in line with the master plan (In the sense of removing a uop, jit does run). But this PR does pass the test from: 1533d1d (which has been added here), and succeeds on the script from: #131199. TSAN also doesn't complain on them.
The fast range iterator has been made free-thread safe by reducing the state to a single variable, calculating the length each time it is needed is not horrible. Removed
_ITER_JUMP_RANGE
because the length guard needs to be atomic in _ITER_NEXT_RANGE, it can always be put back as a noop or extra check.Removed the
_PyObject_IsUniquelyReferenced()
checks fromFOR_ITER_RANGE
opcode as they are no longer needed.Took consideration of performance concern in: #129068, timings for this case are as follows:
New gil-enabled build is probably a little faster due to the removal of
_ITER_JUMP_RANGE
.Script:
Latest
pyperformance
bench gives 1% IMPROVEMENT for this PR in free-threaded over main (probably just variance).There are three jit
test_capi.test_opt
tests which fail now, which looks like due to the changes to the micro-op behavior.P.S. No idea why the "generated files up to date" test fails, I did
regen-all
.