Revision: 6349 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6349&view=rev Author: mdboom Date: 2008-10-29 18:26:34 +0000 (Wed, 29 Oct 2008)
Log Message: ----------- PDF speed optimization. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-10-29 17:16:02 UTC (rev 6348) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-10-29 18:26:34 UTC (rev 6349) @@ -112,7 +112,7 @@ result.append(' '.join(strings[lasti:])) return '\n'.join(result) - +_string_escape_regex = re.compile(r'([\\()])') def pdfRepr(obj): """Map Python objects to PDF syntax.""" @@ -138,7 +138,7 @@ # simpler to escape them all. TODO: cut long strings into lines; # I believe there is some maximum line length in PDF. elif is_string_like(obj): - return '(' + re.sub(r'([\\()])', r'\\\1', obj) + ')' + return '(' + _string_escape_regex.sub(r'\\\1', obj) + ')' # Dictionaries. The keys must be PDF names, so if we find strings # there, we make Name objects from them. The values may be @@ -207,12 +207,13 @@ class Name: """PDF name object.""" + _regex = re.compile(r'[^!-~]') def __init__(self, name): if isinstance(name, Name): self.name = name.name else: - self.name = re.sub(r'[^!-~]', Name.hexify, name) + self.name = self._regex.sub(Name.hexify, name) def __repr__(self): return "<Name %s>" % self.name This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins