Repository navigation
$RecursionLimit: default and maximum are 1024, as in WMA - #2128
Merged
Merged
Conversation
The default was 200 and the largest value that could be set was 512. Wolfram Engine 15 has $RecursionLimit = 1024. MathicsSession.reset() now also resets Python's recursion limit. It gave back the default $RecursionLimit but left Python's limit at whatever the last assignment had set, so a recursion could stop before $RecursionLimit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
@tombouctou sorry my merge didn't do the right thing. I can't look at to fix right now though. |
Member
|
@tombouctou, please double-check the merge I made with master, and merge this in when you are satisfied. |
Correct some typos and improve comments in settings.py The main motivation was changing 1024 to 512 in a comment.
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.
As suggested in #2121: the default
$RecursionLimitgoes from 200 to 1024, the value in Wolfram Engine 15, and the largest value that can be set goes from 512 to 1024 (MATHICS_MAX_RECURSION_DEPTHstill raises it).A bug this exposed
MathicsSession.reset()gave back the default$RecursionLimitbut left Python's recursion limit at whatever the last assignment had set. After$RecursionLimit = 511and a reset, Mathics3 allowed 1024 levels while Python stopped at about 511, andsession.evaluateraisedRecursionError.reset()now restores Python's limit too, with a regression test. The bug is also on master; the higher default makes it visible.Measured
At 1024 on 3.11, 3.12, 3.13 and 3.14 (macOS arm64), on the main thread:
a = a + a, and a definition through PatternTest, Condition and Module) stop with "Recursion depth of 1024 exceeded." The heavier one takes about 0.2 s to abort, against 0.03 s at 200.Trade-offs
SetAttributes[h, HoldAll]; e = Nest[h, x, 60000]),e === e2andFreeQ[e, y]now crash 3.11 with a segmentation fault; at 200 they did not. 3.14 is fine on the same cases, and 3.11 is on its way out.Depthon that same expression takes longer before it aborts: 5.5 s against 0.13 s on 3.14.#2121 still has a comment in
settings.pythat mentions 512, which should change if this goes in first.🤖 Generated with Claude Code