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

Convert Parser's Endless elif to Dict #194

Open
mgeitz opened this issue Mar 30, 2023 · 0 comments
Open

Convert Parser's Endless elif to Dict #194

mgeitz opened this issue Mar 30, 2023 · 0 comments
Labels

Comments

@mgeitz
Copy link
Owner

mgeitz commented Mar 30, 2023

I had no idea python dictionaries supported regex keys..
Profile this structure against the current one. Since either would benefit from frequency analysis it seems like a fair fight.
Trie tree probably doesn't work because it is deterministic.

doh

https://medium.com/@_bryceli/using-dictionaries-as-regex-in-python-de9033bb3e0f

grep r\" parser.py | grep -v return | wc -l
2215

This should help a lot if iterating over a dict is faster, it should at least allow for codeql scanning.

Weighted trie-ish tree would still be fun to try; traverse by word, lower weights on regex matches than literal matches, fall back on leaf nodes ending in a regex to literal string match in dict.

@mgeitz mgeitz added the request label Mar 30, 2023
@mgeitz mgeitz changed the title Convert Parser's endless elif to Dict Convert Parser's Endless elif to Dict Mar 30, 2023
@mgeitz mgeitz changed the title Convert Parser's Endless elif to Dict Convert Parser's Endless elif to Dict or Trie Mar 31, 2023
@mgeitz mgeitz changed the title Convert Parser's Endless elif to Dict or Trie Convert Parser's Endless elif to Dict Apr 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant