-
Notifications
You must be signed in to change notification settings - Fork 0
Memoize some rules to avoid exponential time in deep nesting #39
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
Conversation
The test are failing to download openssl for some reason... :S |
Merging upstream master would probably solve the problem. |
Hummm, merging upstream master in this PR creates a mess. Do you mean merging |
Yes. And then merging |
Sorry for being a bit abrupt amd not explaining things carefully. I'm on my phone. |
No problem, I know that feeling very well :) |
Seems that we need to update pegen to account for python#19283 |
de10536
to
320c0c5
Compare
What about |
I tried with: del a.a.a.a.a......a.a (more than 4000) and seems to parse fine. Could you double check? |
I tried and something like Edit: PR updated |
Additionally, fix the script to calculate the nesting level using the generated extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Also, really good catch! Thanks, Pablo!
Edit: I forgot something. Before we merge this, have you measured what the memory cost is for these changes? Maybe the PEP will need updating.
It increased 0.62% parsing xxl.txt and 0.83% parsing |
Checked also with the largest python file in the standard library ( |
Are you ok with these results for landing this? :) |
How does it compare to the current parser now? Still a little bit ahead? |
The speed seems untouched (maybe a bit faster due to the extra memoization) if you parse something that relies heavily on |
Of course, I'm working on a bug-fix for #38 and I'll verify everything right afterwards. Shouldn't be long. |
Oops! Sorry, accidentally pushed the wrong button. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I discovered that script was broken when moving the code into the cpython repo, but didn't take time to look into it.
Any chance of also committing the script you used to plot the times? (In a separate PR if you need to clean it up first.)
Verified everything. My measurements are very similar to those by @pablogsal. Everything that was too difficult to parse before, can be parsed smoothly now. So let's land this. |
I confirmed the quadratic behavior as well, and the fix works. Land it. |
I will make another PR once I clean it up a bit :) |
Thanks for the reviews and the confirmation of the problem! |
Additionally, fix the script to calculate the nesting level using the
generated extension.
Closes: #37