-
Notifications
You must be signed in to change notification settings - Fork 862
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
SmartyPants is very slow #1103
Comments
This does not surprise me. I always objected to Smartypants being a Markdown extension instead of an external post processor. It was never designed to be performant. You have 2 options:
|
Can you provide an example site on which it is slow? |
No, I ended up removing Python-Markdown because of this problem. But it should be rather trivial to reproduce: try to parse a substantial (2000 word) Markdown document 60 times, and time it with and without using the SmartyPants extension. |
I have looked into this, and the implementation is indeed fundamentally slow. Some small things can be done, but no real solution in sight.
Neither of the two is the clear bigger bottleneck. This behavior is basically how full extensibility via plugins is ensured, and trying to rework or even just trying to optimize the lookbacks risks subtly breaking any of the downstream plugins. But all I've said so far applies generally to all InlineProcessors (of which there are very many for various core features).
So, the small things that can be done:
|
I am the original author of this extension, but unfortunately I don’t have enough time to dig into this. So the only thing I can say is that PRs are welcome. |
I find that markdown.markdown (md to html conversion) is bogged down due to embedded html with < or > enclosing it. It seems the algorithm is slow because it does character by character parsing rather than perhaps looking for '<' and '>' in regex and then marking the location in the file so it can be parsed and apparently removed and then reinserted. I am considering working around this issue by inserting the html after the conversion. Not sure if this has anything to do with "SmartyPants", I am speaking about markdown.markdown(). |
When I am parsing 64 Markdown articles with Python-Markdown, it was taking a little bit over 4 seconds, 3.1 of which was from the SmartyPants extension. It's so much slower than any other extension. Not sure if this is known or not, if you consider it a bug, but wanted to bring it to your attention and ask if this is expected.
The text was updated successfully, but these errors were encountered: