-
Notifications
You must be signed in to change notification settings - Fork 97
save() is very slow #25
Comments
This is caused by a bad dependency on pyparsing. The code used validate path data calls pyparsing, which is a notoriously slow library. I have a patched fork that removes the dependency, but I am not going to guarantee its maintenance over time. I was able to improve runtime of save from "arbitrarily slow" to about 100ms per call. |
The same is accomplished by setting debug=False in svgwrite.Drawing() without removing the whole validator. |
Well that is much easier. @mozman this is such an egregious difference in runtime and well hidden in your code that you should really consider documenting it explicitly or changing the default, because debug mode is on by default. |
Help on documentation is also appreciated ;). |
Wouldn't you rather turn off debug mode by default? I tried changing debug=False in params.py, and it worked, but too many tests started failing and it was unclear where to insert "debug=True" to get them to pass again. I suppose I could also turn it off by default just in the Drawing class init... |
No, this is the default behavior since 2010. Btw svgwrite without validation is just an ElementTree() wrapper, which is really pointless. If you don't need validation, I would suggest to create your SVG by ElementTree() without an additional dependency, and as bonus you could use the lxml package which is really fast. |
I only use this library for the helpers to make creating svgs more readable, e.g., push_arc and friends, which AFAICT are syntactically valid by construction. I'm quite happy with the results. Using etree defeats readability. I can live with setting debug=False. |
Setting |
It feels like the
save()
function is a magnitude too slow:The above example gives the following output (together with a ~400kB SVG file):
When doing a profile of the code it seems the problem is
etree.tostring()
so I guess the issue should go there instead, but is it possible to do improve something about this in thesvgwrite
as well?The text was updated successfully, but these errors were encountered: