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

bpo-40902: Speed up PEG parser by using Dijkstra's shunting yard algorithm #20696

Closed
wants to merge 19 commits into from

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Jun 7, 2020

@pablogsal pablogsal changed the title bpo-40902: Speed up PEG parser by using operator precedence for binary operators bpo-40902: Speed up PEG parser by using Dijkstra's shunting yard algorithm Jun 8, 2020
@pablogsal
Copy link
Member Author

pablogsal commented Jun 8, 2020

It seems that we need unary operators to participate in order to also add ** to the set of operators...

@gvanrossum
Copy link
Member

gvanrossum commented Jun 10, 2020

@pablogsal How do you feel about this? Should we finish it up (fix the merge conflict) and land it, or abandon?

@pablogsal
Copy link
Member Author

pablogsal commented Jun 10, 2020

@pablogsal How do you feel about this?

I am torn: I really like the speedup but I dislike that some operators have their precedence defined via the new method and some others (unary and **) use the "regular" method. It makes a bit complex to document the grammar as it uses two different methods for the same purpose.

Regarding the code complexity, I think is fine as is very localized and although the algorithm can be a bit more complex because the common stack, I think is readable and small enough to not be a major problem IMHO.

I think that unless we found a straightforward way to include unary operators (so we can also include the right-associative **), I propose to abandon this to not increase the complexity of documenting the grammar (and the grammar itself).

What do you think?

@gvanrossum
Copy link
Member

gvanrossum commented Jun 10, 2020

Agreed. We could shelve it now and consider it if we get demands for a faster parser.

@pablogsal pablogsal closed this Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants