Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83706
| Date | 2015-01-13 18:02 +0100 |
|---|---|
| Subject | Performance in exec environnements |
| From | Jean-Baptiste Braun <jbaptiste.braun@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17684.1421168544.18130.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
Hi,
I'm working on auto-generated python code with the exec function. I've done
some performance benches :
% python -m timeit '1 + 1'
10000000 loops, best of 3: 0.0229 usec per loop
% python -m timeit "exec('1 + 1')"
100000 loops, best of 3: 11.6 usec per loop
-> Maybe creating an exec environnement (I don't know how it works) takes
time. But :
% python -m timeit "1 + 1; 1 + 1"
10000000 loops, best of 3: 0.042 usec per loop
% python -m timeit "exec('1 + 1; 1 + 1')"
100000 loops, best of 3: 15.7 usec per loop
-> As if executing one more 1 + 1 would take 4 more seconds (100000
iterations) in an exec environnement.
Am I missing something or should I expect that result ? What does using
exec imply that causes such a difference ?
Jean-Baptiste Braun
Back to comp.lang.python | Previous | Next — 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