friedererdmann / pymxs_stubs

Stubs and stub generator for PyMXS
MIT License
34 stars 5 forks source link

Optimisation: Pre-compiling the pattern would be more performant. #11

Closed ldunham1 closed 2 years ago

ldunham1 commented 2 years ago

https://github.com/friedererdmann/pymxs_stubs/blob/5f793a81fc621c5ed56dc6c4193cf8f4097bc921/parser.py#L61 Generally I like to pre-compile where possible to reduce overhead. Not a big thing here, but it can noticeably improve performance for lots of iterations.

friedererdmann commented 2 years ago

Thanks! I moved all looping matches to compile 5b6eb65e3caa0be277105706a9a6881b525626b3

From what I read on the subject briefly is that compile gets called internally automatically on match and findall, but making it explicit like this might be a bit faster :)

ldunham1 commented 2 years ago

Yes exactly, it's compiled when the functions are called but precompiling the patterns is usually a good shout when you're compiling the same pattern in a loop :)