Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The first sign of maturity is the discovery that the volume knob also turns to the left.


devel / comp.lang.python / Re: built-in pow() vs. math.pow()

SubjectAuthor
o Re: built-in pow() vs. math.pow()Barry

1
Re: built-in pow() vs. math.pow()

<mailman.2466.1680244784.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22694&group=comp.lang.python#22694

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: bar...@barrys-emacs.org (Barry)
Newsgroups: comp.lang.python
Subject: Re: built-in pow() vs. math.pow()
Date: Fri, 31 Mar 2023 07:39:25 +0100
Lines: 39
Message-ID: <mailman.2466.1680244784.20444.python-list@python.org>
References: <CAPTjJmqALCzLVLjq_rpbEYRZ0BEodWtQpTA_tFAuVoVaahDhtQ@mail.gmail.com>
<AA352654-45CC-46EF-A5C0-C0FFEB564776@barrys-emacs.org>
Mime-Version: 1.0 (1.0)
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de uhCsQZXItFknG37T5HWr3A4z+F/2yXuin4vnJ86MMKuA==
Return-Path: <barry@barrys-emacs.org>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'argument': 0.04; 'math':
0.05; '2023': 0.07; 'mar': 0.07; 'angelico': 0.09; 'cc:addr
:python-list': 0.09; 'floating': 0.09; 'from:addr:barry': 0.09;
'received:217.70': 0.09; 'received:gandi.net': 0.09;
'received:mail.gandi.net': 0.09; 'cc:no real name:2**0': 0.14;
'import': 0.15; 'url:mailman': 0.15; 'barry': 0.16; 'chrisa':
0.16; 'floats.': 0.16; 'from:addr:barrys-emacs.org': 0.16;
'functions.': 0.16; 'integer': 0.16; 'message-id:@barrys-
emacs.org': 0.16; 'rationale': 0.16; 'subject:() ': 0.16;
'wrote:': 0.16; 'thu,': 0.19; 'cc:addr:python.org': 0.20; 'fri,':
0.22; 'version': 0.23; 'anything': 0.25; 'url-
ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'url:listinfo': 0.25; 'cc:2**0': 0.25; 'url-ip:188.166/16': 0.25;
'do,': 0.26; 'function': 0.27; '>>>': 0.28; 'chris': 0.28; 'fact':
0.28; 'module': 0.31; 'url-ip:188/8': 0.31; 'wondering': 0.31;
'header:In-Reply-To:1': 0.34; "it's": 0.37; 'this.': 0.37; 'use':
0.39; 'want': 0.40; 'should': 0.40; 'similar': 0.65; 'named':
0.65; 'received:217': 0.67; 'cost': 0.69; 'strong': 0.69;
'subject:. ': 0.73; 'feature,': 0.84; 'lacks': 0.84; 'oscar':
0.84; 'surprised': 0.84
In-Reply-To: <CAPTjJmqALCzLVLjq_rpbEYRZ0BEodWtQpTA_tFAuVoVaahDhtQ@mail.gmail.com>
X-Mailer: iPad Mail (20D67)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
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: <https://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>
X-Mailman-Original-Message-ID: <AA352654-45CC-46EF-A5C0-C0FFEB564776@barrys-emacs.org>
X-Mailman-Original-References: <CAPTjJmqALCzLVLjq_rpbEYRZ0BEodWtQpTA_tFAuVoVaahDhtQ@mail.gmail.com>
 by: Barry - Fri, 31 Mar 2023 06:39 UTC

> On 30 Mar 2023, at 22:30, Chris Angelico <rosuav@gmail.com> wrote:
>
> On Fri, 31 Mar 2023 at 08:13, Oscar Benjamin <oscar.j.benjamin@gmail.com> wrote:
>>
>>> On Thu, 30 Mar 2023 at 17:31, Andreas Eisele <andreas.eisele@gmail.com> wrote:
>>>
>>> I sometimes make use of the fact that the built-in pow() function has an optional third argument for modulo calculation, which is handy when dealing with tasks from number theory, very large numbers, problems from Project Euler, etc. I was unpleasantly surprised that math.pow() does not have this feature, hence "from math import *" overwrites the built-in pow() function with a function that lacks functionality. I am wondering for the rationale of this. Does math.pow() do anything that the built-in version can not do, and if not, why is it even there?
>>
>> It is useful for when you want the pure floating point power which has
>> an approximately fixed computational cost (unlike integer powers).
>> Perhaps it would have been better if it was named fpow similar to fsum
>> vs sum.
>>
>
> It's called math.pow. That on its own should be a strong indication
> that it's designed to work with floats.

So long as you know that the math module is provided to give access the C math.h functions.

Barry

>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor