Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.080 X-Spam-Evidence: '*H*': 0.86; '*S*': 0.02; 'else:': 0.03; 'cc:addr :python-list': 0.11; 'python': 0.11; 'jan': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'function?': 0.16; 'subject:skip:e 10': 0.16; 'xslt,': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'module': 0.19; 'trying': 0.19; 'code,': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'looks': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'markup': 0.31; 'anyone': 0.31; 'file': 0.32; 'actual': 0.34; 'could': 0.34; 'received:google.com': 0.35; '14,': 0.36; 'disk': 0.36; 'possible': 0.36; 'pm,': 0.38; 'read': 0.60; 'entire': 0.61; 'map': 0.64; 'here': 0.66; 'potentially': 0.81; '*and*': 0.84; '2015': 0.84; 'clearer': 0.84; 'quicker': 0.84; 'xslt': 0.84; 'gender': 0.91; 'to:none': 0.92; 'mrs': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=zX/gkkuzwJ5yA5BE23fwT/pNT9uT6WBBgQvTsD7fBp8=; b=T1htEyY9I16EcwyJgn2rAKhVpWM1OEcrqiE4V3a02sU6Ke9YRI1Inq2qa0PRsBOtAt RE34KDw3nzQ14MdbCgsjVcZsiZYTWneWa3+ey4bGLfP0CECBSesIdij0WLmxlC8S7mPr PJGeCsXw1Sh3AGYPF5V0zf6sb5oP/T2EXfl2ZSwjdpIOYyWZaKxVHz7fPH4eQTXFJ1e5 lXymfK2tnxgD0xp0oKfVqKE0GrNkwL+H3HdTv1IkOmYLt2V3UefMq7L4F/M4KxEkqzca WAHo9Qda06mCokJR0zKQ1PpKodgHXNQvfbOcpTMUx/TcnvwQNn8ek50t/nfT/9M50ouR 58+A== MIME-Version: 1.0 X-Received: by 10.107.32.138 with SMTP id g132mr3353313iog.43.1421234096580; Wed, 14 Jan 2015 03:14:56 -0800 (PST) In-Reply-To: References: <54b592ac$0$12995$c3e8da3$5496439d@news.astraweb.com> Date: Wed, 14 Jan 2015 22:14:56 +1100 Subject: Re: Performance in exec environnements From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421234104 news.xs4all.nl 2839 [2001:888:2000:d::a6]:57220 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83745 On Wed, Jan 14, 2015 at 8:02 PM, Jean-Baptiste Braun 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 : > > <xsl:choose> > <xsl:when test="gender='M'"> > Mr > </xsl:when> > <xsl:otherwise> > Mrs > </xsl:otherwise> > </xsl:choose> > > > Generated python : > print('') > if gender == 'M': > print('Mr') > else: > print('Mrs') > print('') 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