Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #66600

Re: Does CPython already has Peephole optimizations?

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 <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'cpython': 0.05; 'filing': 0.07; 'variables': 0.07; 'optimizing': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Does': 0.09; 'python': 0.11; 'bug': 0.12; 'article:': 0.16; 'folding.': 0.16; 'pypy.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:already': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'feb': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'byte': 0.24; 'received:comcast.net': 0.24; 'mon,': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'tried': 0.27; 'url:bugs': 0.29; 'am,': 0.29; "doesn't": 0.30; 'code': 0.31; 'constant': 0.31; "d'aprano": 0.31; 'disable': 0.31; 'steven': 0.31; 'probably': 0.32; 'url:python': 0.33; 'not.': 0.33; 'role': 0.34; 'but': 0.35; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'expect': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'simple': 0.61; "you're": 0.61; 'show': 0.63; 'kind': 0.63; 'love': 0.65; 'temporary': 0.65; 'apart': 0.72; 'subject:skip:o 10': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ned Batchelder <ned@nedbatchelder.com>
Subject Re: Does CPython already has Peephole optimizations?
Date Mon, 17 Feb 2014 07:48:00 -0500
References <mailman.7086.1392625473.18130.python-list@python.org> <5301cf82$0$29985$c3e8da3$5496439d@news.astraweb.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host c-50-133-228-126.hsd1.ma.comcast.net
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.3.0
In-Reply-To <5301cf82$0$29985$c3e8da3$5496439d@news.astraweb.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.7092.1392641296.18130.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1392641296 news.xs4all.nl 2943 [2001:888:2000:d::a6]:50728
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:66600

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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