-
-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serialize Lark.grammar (fixes issue #1472) #1506
base: master
Are you sure you want to change the base?
Conversation
How much does this change add to the cache size? (in rough terms) |
In my scenario with a file.lark of 4kb: cache without grammar: 63,994 bytes making an increase of ~52kb As a quick and dirty performance test, I ran my script which uses lark to parse a file and produce a cpp (with jinja) multiple times under different regimes. Without caching: 440ms This shows that there is indeed a noticeable speed benefit even if the cache has become larger, despite the overhead of jinja and the rest of my script. |
How does serializing the grammar make it run faster? It only adds operations, and doesn't remove any. |
According to the above tests, deserialising the grammar from the cache is faster than reproducing it from the source .lark file each time. |
I think you're mistaken. |
If you would like to avoid the cost of de/serialising the grammar by default, I can make its serialisation optional instead, so you must specify cacheWithGrammar=True. |
I prefer Also consider adding text about this in the reconstructor error. |
ed834e6
to
b20cf8b
Compare
b20cf8b
to
f9adb01
Compare
Fixes #1472