| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Adds a tier-2 only `_STORE_SLICE_LIST` op and a guard `_GUARD_THIRD_LIST`, plus an optimizer rule that rewrites generic `_STORE_SLICE` to the list fast path when the LHS container is (or can be guarded as) an exact list. The list path calls a new `_PyList_StoreSlice` helper that adjusts the slice indices and dispatches into `list_ass_slice_lock_held` directly, skipping the slice-object allocation and the generic `PyObject_SetItem` lookup. The tier-1 `_STORE_SLICE` opcode is left unchanged so non-list callers incur no extra branch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Documentation build overview1 file changed ± whatsnew/changelog.html |
Sorry, something went wrong.
Resolved generated pycore_uop_ids.h conflict by regenerating from bytecodes.c / optimizer_bytecodes.c. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
One question, otherwise looks good.
It would be good to optimize constant slices, but that would need a change to the bytecode compiler. For another PR.
Sorry, something went wrong.
Picks up the dead-local removal from the latest commit
('Apply suggestion from @eendebakpt') in optimizer_bytecodes.c.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Ah yes. So the mechanism is: for x[1:2] = ... there is a constant slice. The compiler optimizes this to LOAD_CONST and STORE_SUBSCR (which is not specialized), which means we will never get to the specialized STORE_SLICE introduced in this PR. We could:
I am leaning towards the second option (initially only in tier2 to avoid adding a tier1 opcode). Update: a branch with STORE_SUBSCR specialized is main...eendebakpt:cpython:gh-131798-store-subscr-list-slice, but there is hardly any performance gain. |
Sorry, something went wrong.
|
This PR is stale because it has been open for 90 days with no activity. |
Sorry, something went wrong.
|
This PR is superseded by #157011, a newer open pull request for the same issue (gh-131798), and it no longer merges cleanly. Closing to cull the number of open pull requests. Do not reopen this pull request without getting a go-ahead from a triager or core developer. Sorry, incorrectly flagged as a duplicate. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
The JIT currently dispatches STORE_SLICE (container[start:stop] = value) through PyObject_SetItem even when the trace has proven the container is an exact list. Adding a tier-2 specialization _STORE_SLICE_LIST skips the slice-object allocation and the generic lookup.
The optimizer rewrites _STORE_SLICE → _STORE_SLICE_LIST only when the container's type is statically known, so non-list callers and tier-1 are unaffected. A second commit for bytearray was added but reverted.
Benchmark results on pyperformance fannkuch (tier-2 / JIT enabled):