Parsing of paths is very time-consuming
In the interactive session quoted below, I create a drawing containing one element, a path with 5,001 commands. It takes nearly a minute to save.
Python 3.3.0 (default, Nov 23 2012, 10:26:01) [GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import svgwrite >>> d = svgwrite.Drawing(filename='test.svg') >>> p = d.path() >>> d.add(p) <svgwrite.path.Path object at 0x124deadd0> >>> p.push(['M', 0, 0]) >>> for i in range(5000): ... p.push(['L', i, 0]) ... >>> from timeit import timeit >>> timeit(d.save, number=1) 59.46839178504888
debug=False, saving is essentially instant (0.04 seconds). So clearly something is going wrong in the validation of the path. I'm guessing that the path parser has the wrong complexity: perhaps all those
ZeroOrMore productions end up getting backtracked?