Repository navigation
Conversation
repr/str/hash/len/chr/ord/int/bool/abs fold to const nodes when the argument is compile-time constant. eval folds only through ast.literal_eval with a scalar result; hash folds only on int/bool; chr only inside Latin-1; int of text keeps ps_int_from_bytes.
Oracle-diff vs CPython including repr edge chars; fence assertions for arbitrary eval/exec, non-scalar eval, and hash of text. module_cond: len(NAME) folding makes the annotated assignment a constant again.
Contributor
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Deploying pyscriptc with
|
| Latest commit: |
7be3256
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://81500b57.pyscriptc.pages.dev |
| Branch Preview URL: | https://work-t2-static-folds.pyscriptc.pages.dev |
This branch has not been deployed
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
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.
Summary
Tier-2 static folds per
.agents/plans/2026-10-18-tiered-lowering-and-typefacts.md:repr/str/hash/len/chr/ord/int/bool/abson compile-time-constant arguments now lower to const nodes instead of runtime calls. Non-foldable args fall through to the same handlers/fences as before — no fence message reworded.Fold boundary (documented in the plan file):
eval(<string-const>)folds only throughast.literal_evalwith a scalar result; arbitraryeval/execstay fenced (tier-3 dynamic).hashfolds only on int/bool — str/bytes hashing is seed-randomized in CPython.chrfolds only inside the Latin-1 literal range (PS2005 boundary);ordonly on single chars.intof str/bytes consts keeps theps_int_from_bytespath so the subset's i64 fence and underscore rejection survive.lenof a list/dict literal folds only when every element is itself a const (a call element's side effect must survive).tests/test_t2_static_folds.pyoracle-diffs compiled stdout against CPython, including repr edge chars (embedded quotes, escapes,\n,é,b"\x00\xff"), pins the folded IR shape (nocallnodes), and pins the remaining fences.test_module_cond:len(NAME)folding makes the annotated module assignment a constant again, so the twolen()cases moved to a new un-fenced test.Frozen
test_census_self: self-census is now modules 27, lines 20571, fences 1031 (+8 from the new lowering code).uv run pytestgreen apart from that frozen pin and pre-existingbenchmarks/compat2/cache.py(py314except A, B:under the 3.13 venv, fails on master too).ruff check/ruff formatclean on changed files.Link to Devin session: https://app.devin.ai/sessions/f0b00d23411743adb8c2fc49b42b2611
Open in Devin Desktop: https://app.devin.ai/desktop/session/f0b00d23411743adb8c2fc49b42b2611?variant=devin
Requested by: @espetro