Performance in exec environnements

Chris Angelico rosuav at
Wed Jan 14 12:14:56 CET 2015

On Wed, Jan 14, 2015 at 8:02 PM, Jean-Baptiste Braun
<jbaptiste.braun at> 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.


More information about the Python-list mailing list