Performance in exec environnements
Chris Angelico
rosuav at gmail.com
Wed Jan 14 06:14:56 EST 2015
On Wed, Jan 14, 2015 at 8:02 PM, Jean-Baptiste Braun
<jbaptiste.braun at gmail.com> wrote:
> What I'm trying to do is to map a transformation description in a markup
> langage (XSLT) in python to improve execution time. Here is a simplification
> of what it looks like :
>
> XSLT :
> <title>
> <xsl:choose>
> <xsl:when test="gender='M'">
> Mr
> </xsl:when>
> <xsl:otherwise>
> Mrs
> </xsl:otherwise>
> </xsl:choose>
> </title>
>
> Generated python :
> print('<title>')
> if gender == 'M':
> print('Mr')
> else:
> print('Mrs')
> print('</title>')
Would it be possible to do a one-off transformation of the entire XSLT
file into a Python module with a single function in it, and then every
time you need that XSLT, you import that module and call the function?
That would potentially be a lot quicker than exec(), *and* would be
much clearer - there'd be an actual file on the disk with your
generated Python code, and anyone could read it and understand what
it's doing.
ChrisA
More information about the Python-list
mailing list