Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83745
| References | <mailman.17684.1421168544.18130.python-list@python.org> <54b592ac$0$12995$c3e8da3$5496439d@news.astraweb.com> <CABUUr0yYBM=EJpcZXX2mJ0pz13Tum8px3Z8y3EZcr0VEo6Bfpw@mail.gmail.com> |
|---|---|
| Date | 2015-01-14 22:14 +1100 |
| Subject | Re: Performance in exec environnements |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17713.1421234104.18130.python-list@python.org> (permalink) |
On Wed, Jan 14, 2015 at 8:02 PM, Jean-Baptiste Braun
<jbaptiste.braun@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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Performance in exec environnements Jean-Baptiste Braun <jbaptiste.braun@gmail.com> - 2015-01-13 18:02 +0100
Re: Performance in exec environnements Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-14 08:48 +1100
Re: Performance in exec environnements Jean-Baptiste Braun <jbaptiste.braun@gmail.com> - 2015-01-14 10:02 +0100
Re: Performance in exec environnements Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-15 12:51 +1100
Re: Performance in exec environnements Chris Angelico <rosuav@gmail.com> - 2015-01-14 22:14 +1100
Re: Performance in exec environnements Jean-Baptiste Braun <jbaptiste.braun@gmail.com> - 2015-01-14 14:38 +0100
Re: Performance in exec environnements Chris Angelico <rosuav@gmail.com> - 2015-01-15 00:43 +1100
Re: Performance in exec environnements Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-14 10:11 -0700
csiph-web