Skip to content

Performance considerations when generating parser for a long list of words #85

Answered by renggli
venkatd asked this question in Q&A
Discussion options

You must be logged in to vote

The code is not automatically optimized to match a large number of choices as described in the example. PetitParser will literally do a case-insensitive prefix match for every single location in your list. Though I don't think this is necessarily a problem and I wouldn't worry about optimizing at this point. Get it working correctly first, and then — if necessary — profile and improve the performance as needed. I see various ways of effectively optimizing:

  1. Parse the location like a generic variable name and do a separate lookup in the parse action afterwards (might not work without other tricks, if locations are not clearly separated),
  2. Try to build a smarter parse graph (i.e. a prefix tr…

Replies: 8 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by renggli
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #85 on December 08, 2020 19:53.