Repository navigation
Redesign kitAST.oeis: Default/override generators, 8x faster regeneration - #39
Merged
Merged
Conversation
Regenerating byFormula, its tests, and their samples took 2m44s; it takes about 20s now, with identical generated code. - Relation tests: instantiate each side once. The old path substituted n into the whole Equality, so SymPy tried to decide equality of unknown sequence values, then substituted into each side again. `_symbolic.makeInstancesRelation` replaces `makeIndicesRelation` and `expressionStored吗`. - Autoflake keeps `ignore_pass_statements`: its useless-pass scan is quadratic and costs minutes on the 2 MB relation-test module. - Modules: `makeModules` (makeModulesOEIS), `_byFormula`, `_parametersTest`, `_tests`, replacing oeisModules, oeisIDByFormula, and oeisTests. - Each generator takes `identifiers` and `**override`; `defaultOEIS` holds the module names, logical paths, test names, and the samples variable, so the test modules import byFormula and the samples through identifiers instead of literals. `resolvePathFilenameModule` holds the path resolution that `toDisk` used. - Solutions are identified by their selector once (`makeLookupSolutions`, `形Solution`) instead of recomputing selectors for every test request. - Generated modules take their docstrings from IngredientsModule; the Contents section is omitted when a module has no public function, and an entry omits an empty summary line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GMd3z8jjYb2eqKRTMNwbAH
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
Regenerating
byFormula.py,test_byFormula.py,test_relationsTriangle.py, andtests/dataSamples/oeis.pytook 2m44s. It now takes about 20s. Apart from module docstrings, the generated code is identical: I compared ASTs against the original generator's output from a worktree atmain.Where the time went
makeIndicesRelationsubstitutedninto the wholeEquality, so SymPy tried to decide whether expressions of unknown sequence values are equal. TheninstantiateSidesubstituted into each side again._symbolic.makeInstancesRelationnow substitutes and evaluates each side once and checks the stored values on the result. It replacesmakeIndicesRelationandexpressionStored吗.passscan is quadratic: 163s on the 2 MB relation-test module. The oldignore_pass_statements: Truesetting avoided it, so the generated modules keep that setting.makeBoxOf_ffor every request. They are now computed once.Design
makeModules(makeModulesOEIS),_byFormula,_parametersTest, and_tests. They replaceoeisModules,oeisIDByFormula, andoeisTests.makeByFormula,makeTestsByFormula,makeTestsTriangle,makeSamples) takesidentifiers: Default | Noneand**override: Unpack[DefaultOverride]. A newdefaultOEISinkitAST.theSSOTholds the module names, logical paths, test-function names, and the samples variable. The test modules now importbyFormulaand the samples through those identifiers instead of string literals.resolvePathFilenameModule(kitAST._beDRY) is the path resolution thattoDiskused.makeSamplesuses it to read its previous output. The other generators still write byte-identical files.makeLookupSolutionsidentifies each solution of a sequence by its selector once (形Solution). Type aliases形ParameterFormula,形ParameterRelation, and形Referencereplace the repeated tuple types.IngredientsModule.docstring. TheContentssection is now omitted for a module without public functions, and an entry omits an empty summary line instead of leaving trailing whitespace.Testing
pytestontest_byFormula.py,test_relationsTriangle.py,test_oeis.py,test_kitAST.py, andtest_pyproject.py: 7182 passed, 1 xfailed. 2 errors aretest_optionalDependenciesfor theoeisdataandortoolsextras, which are not installed in this environment.synthesizeModules.cmd, produce no diff.byFormula.pyis committed with only its new docstring. In this environment, both the old and the new generator order a few SymPy terms differently and reportvalueUnknown301 instead of 401 for A400632 and A400633. That comes from this environment's data, not from this change.Generated by Claude Code