Beta implementation of Just In time parsing#960
Conversation
`g`, and `f`/`e` formatters treat precision differently. `g` is used when there is no reverse engineering occurring, otherwise `f`/`e` are used. Therefore the formatter precision changes meaning. In rounding it is treated as being the number of digits right of the decimal. This logic updates it so when `g` is used it now represents the number of sig figs, so the rounding truncation logic still applies.
Updated default float precision to be basically machine precision.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…-tests Fixed deprecated test fixtures breaking tests
Bumps [actions/checkout](https://github.com/actions/checkout) from 6.0.2 to 6.0.3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@de0fac2...df4cb1c) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: 6.0.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
…ns/checkout-6.0.3 Bump actions/checkout from 6.0.2 to 6.0.3
Started testing against python 3.15 dev releases.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…st arg. cell.py was missing `Annotated` in its imports despite using it directly in the lattice_type setter annotation under `from __future__ import annotations`, and had `true` (lowercase) instead of `True`. Also removed the `jit_parse` keyword argument from test_arbitrary_parse that parse() never accepted. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Observation: JIT significantly reduces memory usage--less memory allocation and more garbage collection So far JIT somewhat inflates loading time. Without JIT: 31 s. With JIT: 69s, for the benchmark. Reading a large reactor model with depletion on my desktop, loading time increased from 41 to 46 s. |
| if len(input.input_lines) > 0: | ||
| try: | ||
| obj = obj_parser(input) | ||
| obj = obj_parser(input, problem=self, jit_parse=jit_parse) |
There was a problem hiding this comment.
jit_parse doesn't seem to propagate to the objects.
>>> deck0 = montepy.read_input("tests/inputs/test.imcnp", jit_parse=False)
>>> deck0.cells[3]
Cell('3 3 -1\n 1000 1005 -1010\n imp:n,p=1', number=3, jit_parse=False)
>>> deck1 = montepy.read_input("tests/inputs/test.imcnp", jit_parse=True)
>>> deck1.cells[3]
Cell('3 3 -1\n 1000 1005 -1010\n imp:n,p=1', number=3, jit_parse=False)There was a problem hiding this comment.
I think somewhere a full parse is getting triggered during the full model reading process.
I suspect the overhead is due to |
Pull Request Checklist for MontePy
Description
This PR adds the ability to do Just-in-time parsing. The quick summary is that at file read time, only the very beginning (3 words max per object) are read and used to store the object in the "proper place" then when more information is needed from that object it is
full_parsed, and the data are stored so it may be accessed. Here's an overview of how that was done:__init__to a hook based system with_init_blank,_parse_tree, etc. To make the code more DRY.jit_parseargs to__init__and defaulted tojit_parse.full_parsethat essentially triggers a re-initneeds_full_cstandneeds_full_astto mark functions that need full abstract/concrete syntax trees. Right now they are identical, but they could be used in the future. When a function that is marked is called it is checked if it is fully parsed, if not a full parse occurs.update_pointersFor more details read the updated dev docs.
I know this is a ton @tjlaboss. I am thinking of having you review just the architecture, and then calling that good before doing a beta release. For testing I found a way to have all of the integration tests to run with both
jit_parse=Falseandjit_parse=Truepretty cleanly with pytest (thanks Claude).TODO:
Fixes #529
General Checklist
blackversion 25 or 26.LLM Disclosure
Are you?
Were any large language models (LLM or "AI") used in to generate any of this code?
Documentation Checklist
First-Time Contributor Checklist
pyproject.tomlif you wish to do so.Additional Notes for Reviewers
Ensure that:
📚 Documentation preview 📚: https://montepy--960.org.readthedocs.build/en/960/