Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25786
| References | <mailman.2364.1342856185.4697.python-list@python.org> <500a711f$0$29978$c3e8da3$5496439d@news.astraweb.com> |
|---|---|
| From | Devin Jeanpierre <jeanpierreda@gmail.com> |
| Date | 2012-07-21 21:31 -0400 |
| Subject | Re: Basic question about speed/coding style/memory |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2410.1342920734.4697.python-list@python.org> (permalink) |
On Sat, Jul 21, 2012 at 5:06 AM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > So there is approximately 0.03 second difference per TWO MILLION > if...else blocks, or about 15 nanoseconds each. This is highly unlikely > to be the bottleneck in your code. Assuming the difference is real, and > not just measurement error, the difference is insignificant. It's probably real. For if-else, the true case needs to make a jump before it returns, but for if-return, there's no jump and the return is inlined. -- Devin > So, don't worry about which is faster. Write whichever is more natural, > easier to read and write. The most important advice. Even when it's a larger difference! :) -- Devin
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Basic question about speed/coding style/memory Jan Riechers <janpeterr@freenet.de> - 2012-07-21 10:33 +0300
Re: Basic question about speed/coding style/memory Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-21 09:06 +0000
Re: Basic question about speed/coding style/memory Jan Riechers <janpeterr@freenet.de> - 2012-07-21 12:32 +0300
Re: Basic question about speed/coding style/memory Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-21 21:31 -0400
Re: Basic question about speed/coding style/memory Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-07-21 21:19 +0200
Re: Basic question about speed/coding style/memory 88888 Dihedral <dihedral88888@googlemail.com> - 2012-07-23 14:42 -0700
Re: Basic question about speed/coding style/memory 88888 Dihedral <dihedral88888@googlemail.com> - 2012-07-23 14:42 -0700
csiph-web