-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
_PyPegen_is_memoized() has a complexity of O(n) #93289
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
Comments
@pablogsal @lysnikolaou @isidentical: Would it be possible to maintain a hashtable to make this lookup function faster? If you consider that it's not worth it, just you can close my issue ;-) |
The benchmark comes from: #93106 |
We already tried to use a hash table, a btree, a static array, a dynamic array and a skip list and all of them were slower. If you manage to get a hash table to perform faster, I'm happy to merge it :) |
I tried yet again to use the hash table from I'm closing the issue, but if you manage to get a hash table or other structure running and is faster, please feel free to reopen. |
@isidentical @lysnikolaou If you want to give it a go, please feel free to try :) |
That's what I would try. I trust you that it's worse ;-) Ok, good that you already knew about it! |
Using Linux perf, I noticed that the Python parser spends a significant time in the _PyPegen_is_memoized() function which iterates on a linked list to find a value:
script.py:
Linux perf says that overall, Python spent 7% of its runtime in this function:
The text was updated successfully, but these errors were encountered: