[MNT]: mathtext.MathTextParser is slow #20821
Comments
Effectively re-writing the mathtext module does not seem a small project (as I assume the output of the parsing step will be different enough that we will have to re-write the code that consumes it). It might be a good GSOC project? A less invasive fix would might to add some strategic If your text is not changing frequently you may also get a speed win (at the cost of an expensive first draw) by switching to |
It is probably not easy to replace the parser, true. The hot-fix for my app was to remove all LaTeX, which produced a perceivable performance gain. Some of the LaTeX was static, some was dynamically changing. I did not try to remove only the dynamic components which cannot be cached. |
Summary
The mathtext.MathTextParser is a performance bottleneck.
I profiled my interactive app that uses PyQt and matplotlib to draw complex plots with very little text and yet significant time (20 %) is spend in the mathtext.MathTextParser. See
profile_graph.pdf
Proposed fix
The parser is using pyparsing internally and could potentially be speed up by switching to lark.
The text was updated successfully, but these errors were encountered: