Skip to content
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

Earley now uses OrderedSet for better output stability #1327

Merged
merged 4 commits into from
Oct 2, 2023
Merged

Conversation

erezsh
Copy link
Member

@erezsh erezsh commented Aug 23, 2023

Addresses issue #1325, and others

@erezsh erezsh requested a review from MegaIng August 23, 2023 08:50
@erezsh erezsh force-pushed the orderedset branch 2 times, most recently from 17dbcfa to 40228c6 Compare August 23, 2023 09:00
@erezsh
Copy link
Member Author

erezsh commented Aug 23, 2023

@MegaIng @chanicpanic This change makes Earley approx 10% slower. (on a very simple benchmark)

Do you think the stability it provides is worth it? (let's assume it gives us 100% output stability)

@MegaIng
Copy link
Member

MegaIng commented Aug 23, 2023

Maybe have an option that can change it, but default to the slower, stable version?

Also, I didn't check that this actually hits all locations, I assume you just searched for references to set.

@chanicpanic
Copy link
Contributor

I like the idea of having an option to enable/disable it.

Defaulting to the stable version would be more user-friendly. The slowdown is unfortunate, but it is consistent with Lark positioning Earley as the parser for power and LALR as the parser for speed.

On the other hand, in addition to performance, it could be argued that defaulting to the unstable version has the benefit of exposing undesirable ambiguity and forcing grammar authors to remove/resolve it.

@erezsh erezsh force-pushed the orderedset branch 3 times, most recently from b0c4fed to 088197e Compare September 22, 2023 21:35
@codecov-commenter
Copy link

codecov-commenter commented Sep 22, 2023

Codecov Report

Patch coverage: 92.98% and project coverage change: +0.02% 🎉

Comparison is base (c2e44ea) 89.23% compared to head (41c28d4) 89.26%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1327      +/-   ##
==========================================
+ Coverage   89.23%   89.26%   +0.02%     
==========================================
  Files          51       51              
  Lines        7591     7612      +21     
==========================================
+ Hits         6774     6795      +21     
  Misses        817      817              
Flag Coverage Δ
unittests 89.26% <92.98%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
lark/load_grammar.py 92.60% <50.00%> (ø)
lark/parsers/earley_forest.py 77.94% <87.50%> (+0.19%) ⬆️
lark/utils.py 86.66% <93.75%> (+0.51%) ⬆️
lark/parsers/earley.py 82.65% <94.73%> (+0.57%) ⬆️
lark/lark.py 85.66% <100.00%> (+0.04%) ⬆️
lark/parser_frontends.py 95.90% <100.00%> (ø)
lark/parsers/xearley.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@erezsh
Copy link
Member Author

erezsh commented Sep 22, 2023

@MegaIng @chanicpanic take 2

lark/lark.py Outdated Show resolved Hide resolved
lark/parser_frontends.py Outdated Show resolved Hide resolved
lark/parsers/earley.py Outdated Show resolved Hide resolved
lark/lark.py Outdated Show resolved Hide resolved
lark/parsers/xearley.py Outdated Show resolved Hide resolved
lark/parsers/earley.py Outdated Show resolved Hide resolved
@erezsh erezsh merged commit 12ac446 into master Oct 2, 2023
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants