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

Consider rewriting slow parts in rust #490

Open
jonathan-s opened this issue Jun 29, 2023 · 4 comments
Open

Consider rewriting slow parts in rust #490

jonathan-s opened this issue Jun 29, 2023 · 4 comments

Comments

@jonathan-s
Copy link

I have program that runs the function parse_string from pyparsing 402 times, and the cumulative time this takes is 1.242s. It would most definitely speed up this library if slow parts were outsourced into rust.

@ptmcg
Copy link
Member

ptmcg commented Jun 29, 2023

There is a cPyparsing project that was built by Evan Hubinger that he used for his coconut language parser. It uses cython to speed up the parsing process.

@ptmcg
Copy link
Member

ptmcg commented Jun 29, 2023

Have you tried enabling packrat parsing? This is especially helpful if you include an infix_notation expression as part of your parser.

Here is a wiki page with more performance suggestions: https://github.com/pyparsing/pyparsing/wiki/Performance-Tips

@jonathan-s
Copy link
Author

Thanks! I'll explore this and see if it makes a difference!

@ptmcg
Copy link
Member

ptmcg commented Jul 29, 2023

Any further notes on this?

One of the core dev goals for pyparsing is to maintain pure Python-ness, so that it is easy to install in any Python-compatible environment. So actually using Rust or C or other speed up is not consistent with that. Also, pyparsing's internal implementation using Python exceptions to signal parsing success/failure is really where most of the performance time goes.

I'll take a look at what Evan Hubinger has done with cPyparsing to see where using Cython has sped things up, and see if that gives me any ideas on pure-Python options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants