Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66600
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Subject | Re: Does CPython already has Peephole optimizations? |
| Date | 2014-02-17 07:48 -0500 |
| References | <mailman.7086.1392625473.18130.python-list@python.org> <5301cf82$0$29985$c3e8da3$5496439d@news.astraweb.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.7092.1392641296.18130.python-list@python.org> (permalink) |
On 2/17/14 3:59 AM, Steven D'Aprano wrote: > On Mon, 17 Feb 2014 13:54:25 +0530, Laxmikant Chitare wrote: > >> I read about this article: >> http://www.python.org/workshops/1998-11/proceedings/papers/montanaro/ > montanaro.html >> >> Just wanted to clarify whether CPython already includes these kind of >> byte code optimizations? Are all the temporary variables removed when >> byte code is generated? > > > You can check these things for yourself: > > import dis > dis.dis(function) > > > will show you the byte code. > > But in general, I would expect not. CPython (that's the Python you > probably use) doesn't do a lot of optimization apart from some simple > constant folding. If you're interested in optimizing Python, you should > look at the JIT optimizing Python compiler, PyPy. > > CPython does some constant folding, and also jump optimizations. In my role as coverage.py maintainer, I would love to see a way to disable all those optimizations. I tried filing a bug about it (http://bugs.python.org/issue2506), but it did not win the popular support I had hoped for. -- Ned Batchelder, http://nedbatchelder.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Does CPython already has Peephole optimizations? Laxmikant Chitare <laxmikant.general@gmail.com> - 2014-02-17 13:54 +0530
Re: Does CPython already has Peephole optimizations? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-17 08:59 +0000
Re: Does CPython already has Peephole optimizations? Ned Batchelder <ned@nedbatchelder.com> - 2014-02-17 07:48 -0500
Re: Does CPython already has Peephole optimizations? Terry Reedy <tjreedy@udel.edu> - 2014-02-17 08:51 -0500
Re: Does CPython already has Peephole optimizations? Laxmikant Chitare <laxmikant.general@gmail.com> - 2014-02-18 10:41 +0530
csiph-web