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


Groups > comp.lang.python > #61268

Re: Does Python optimize low-power functions?

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <torriem+gmail@torriefamily.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.019
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'interpreter': 0.05; 'subject:Python': 0.06; 'subject:Does': 0.09; 'python': 0.11; 'bytecode': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'nick': 0.16; 'sorts': 0.16; 'underlying': 0.16; 'wrote:': 0.18; 'appears': 0.22; 'import': 0.22; 'header:User- Agent:1': 0.23; 'byte': 0.24; 'example.': 0.24; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'code': 0.31; '>>>>': 0.31; 'sep': 0.31; 'yourself.': 0.31; 'could': 0.34; "can't": 0.35; '(2)': 0.35; 'done.': 0.35; 'but': 0.35; 'subject:?': 0.36; 'being': 0.38; 'message-id:@gmail.com': 0.38; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'extremely': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'easy': 0.60; 'tell': 0.60; 'more': 0.64; 'great': 0.65; 'answered,': 0.84; '2013,': 0.91
X-Virus-Scanned amavisd-new at torriefamily.org
Date Sat, 07 Dec 2013 19:00:09 -0700
From Michael Torrie <torriem@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130105 Thunderbird/10.0.12
MIME-Version 1.0
To python-list@python.org
Subject Re: Does Python optimize low-power functions?
References <5ea86e1b-f5b5-49d1-acfb-22ee4d9a1f16@googlegroups.com> <64aa230f94f04c938101f928ac1a0276@DM2PR06MB542.namprd06.prod.outlook.com>
In-Reply-To <64aa230f94f04c938101f928ac1a0276@DM2PR06MB542.namprd06.prod.outlook.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
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.3716.1386468041.18130.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1386468041 news.xs4all.nl 2829 [2001:888:2000:d::a6]:35412
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:61268

Show key headers only | View raw


On 12/06/2013 12:32 PM, Nick Cash wrote:
> Nope:
> 
> Python 3.3.0 (default, Sep 25 2013, 19:28:08) 
> [GCC 4.7.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import dis
>>>> dis.dis(lambda x: x*x)
>   1           0 LOAD_FAST                0 (x) 
>               3 LOAD_FAST                0 (x) 
>               6 BINARY_MULTIPLY      
>               7 RETURN_VALUE         
>>>> dis.dis(lambda x: x**2)
>   1           0 LOAD_FAST                0 (x) 
>               3 LOAD_CONST               1 (2) 
>               6 BINARY_POWER         
>               7 RETURN_VALUE         
> 
> 
> The reasons why have already been answered, I just wanted to point
> out that Python makes it extremely easy to check these sorts of
> things for yourself.

But this is just the interpreter bytecode that dis is showing.  It's not
showing the underlying implementation of binary_power, for example.
That could be defined in C code with any number of optimizations, and
indeed it appears that some are being done.  dis is great for showing
how python code breaks down, but it can't tell you much about the code
that underlies the byte codes themselves.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Does Python optimize low-power functions? John Ladasky <john_ladasky@sbcglobal.net> - 2013-12-06 10:16 -0800
  Re: Does Python optimize low-power functions? Neil Cerutti <neilc@norwich.edu> - 2013-12-06 19:01 +0000
  Re: Does Python optimize low-power functions? Robert Kern <robert.kern@gmail.com> - 2013-12-06 19:12 +0000
  RE: Does Python optimize low-power functions? Nick Cash <nick.cash@npcinternational.com> - 2013-12-06 19:32 +0000
    Re: Does Python optimize low-power functions? John Ladasky <john_ladasky@sbcglobal.net> - 2013-12-06 11:43 -0800
  Re: Does Python optimize low-power functions? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-12-06 20:57 +0000
  Re: Does Python optimize low-power functions? Michael Torrie <torriem@gmail.com> - 2013-12-07 19:00 -0700

csiph-web