Re: Performance in exec environnements

2015-01-14 Thread Steven D'Aprano
Jean-Baptiste Braun wrote: > 2015-01-13 22:48 GMT+01:00 Steven D'Aprano < > steve+comp.lang.pyt...@pearwood.info>: > >> So you have been comparing: >> >> 2 >> >> versus >> >> exec('1+1') >> >> >> The first case just fetches a reference to a pre-existing int object, and >> then deletes the

Re: Performance in exec environnements

2015-01-14 Thread Ian Kelly
On Wed, Jan 14, 2015 at 2:02 AM, Jean-Baptiste Braun wrote: > What I don't understand is the ratio between test 2 / 4 and test 1 / 3. > > Let 0.0229 sec be the execution time to read a bytecode (1st test). > Executing two times that bytecode takes 0.042 sec (test 3), which looks > coherent. > > Le

Re: Performance in exec environnements

2015-01-14 Thread Chris Angelico
On Thu, Jan 15, 2015 at 12:38 AM, Jean-Baptiste Braun wrote: > 2015-01-14 12:14 GMT+01:00 Chris Angelico : >> >> 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 t

Re: Performance in exec environnements

2015-01-14 Thread Jean-Baptiste Braun
2015-01-14 12:14 GMT+01:00 Chris Angelico : > 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 q

Re: Performance in exec environnements

2015-01-14 Thread Chris Angelico
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 : > > > >Mr > > >Mrs > >

Re: Performance in exec environnements

2015-01-14 Thread Jean-Baptiste Braun
2015-01-13 22:48 GMT+01:00 Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info>: > So you have been comparing: > > 2 > > versus > > exec('1+1') > > > The first case just fetches a reference to a pre-existing int object, and > then deletes the reference. That's fast. > > The second case:

Re: Performance in exec environnements

2015-01-13 Thread Steven D'Aprano
Jean-Baptiste Braun wrote: > Hi, > > I'm working on auto-generated python code with the exec function. I've > done some performance benches : [snip timing results] > Am I missing something or should I expect that result ? What does using > exec imply that causes such a difference ? exec'ing a

Re: Performance in exec environnements

2015-01-13 Thread Ian Kelly
On Tue, Jan 13, 2015 at 10:02 AM, Jean-Baptiste Braun wrote: > Hi, > > I'm working on auto-generated python code with the exec function. I've done > some performance benches : > > % python -m timeit '1 + 1' > 1000 loops, best of 3: 0.0229 usec per loop > > % python -m timeit "exec('1 + 1')" >