Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Per buck you get more computing action with the small computer. -- R. W. Hamming


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

SubjectAuthor
* built-in pow() vs. math.pow()Andreas Eisele
+- Re: built-in pow() vs. math.pow()Stefan Ram
+- Re: built-in pow() vs. math.pow()Stefan Ram
+- Re: built-in pow() vs. math.pow()Barry Scott
+- Re: built-in pow() vs. math.pow()Barry Scott
+* Re: built-in pow() vs. math.pow()Roel Schroeven
|`- Re: built-in pow() vs. math.pow()Dennis Lee Bieber
+- Re: built-in pow() vs. math.pow()Thomas Passin
+- Re: built-in pow() vs. math.pow()Grant Edwards
+- RE: built-in pow() vs. math.pow()<avi.e.gross
+- Re: built-in pow() vs. math.pow()Oscar Benjamin
+- Re: built-in pow() vs. math.pow()Chris Angelico
`* Re: built-in pow() vs. math.pow()Andreas Eisele
 `- Re: built-in pow() vs. math.pow()2QdxY4RzWzUUiLuE

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

<831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a05:620a:2119:b0:746:8cfa:1934 with SMTP id l25-20020a05620a211900b007468cfa1934mr4571461qkl.4.1680167752084;
Thu, 30 Mar 2023 02:15:52 -0700 (PDT)
X-Received: by 2002:a9d:6a88:0:b0:698:f988:7c3f with SMTP id
l8-20020a9d6a88000000b00698f9887c3fmr7381202otq.6.1680167751825; Thu, 30 Mar
2023 02:15:51 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Thu, 30 Mar 2023 02:15:51 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=158.169.150.14; posting-account=jEtcCwoAAADNlDXdwYCl7UKBmA9fHVUA
NNTP-Posting-Host: 158.169.150.14
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
Subject: built-in pow() vs. math.pow()
From: andreas....@gmail.com (Andreas Eisele)
Injection-Date: Thu, 30 Mar 2023 09:15:52 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Andreas Eisele - Thu, 30 Mar 2023 09:15 UTC

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?
Thanks in advance for any enlightening comment on this.
Best regards, Andreas

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

<pow-20230330105717@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: built-in pow() vs. math.pow()
Date: 30 Mar 2023 09:58:36 GMT
Organization: Stefan Ram
Lines: 34
Expires: 1 Apr 2024 11:59:58 GMT
Message-ID: <pow-20230330105717@ram.dialup.fu-berlin.de>
References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de FlC9Ivlq+5EuJBCfkPOUxgVOkplZqvpQDAynnr1Hn+c4oi
X-Copyright: (C) Copyright 2023 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Thu, 30 Mar 2023 09:58 UTC

Andreas Eisele <andreas.eisele@gmail.com> writes:
>hence "from math import *" overwrites the built-in pow()
>function with a function that lacks functionality.

You can reimport the built-in "pow" after "from math import *":

main.py

from math import *

print( pow.__doc__ )

print( '\n~~\n' )

from builtins import pow

print( pow.__doc__ )

sys.stdout

Return x**y (x to the power of y).

~~

Equivalent to base**exp with 2 arguments or base**exp % mod
with 3 arguments

Some types, such as ints, are able to use a more efficient
algorithm when
invoked using the three argument form.

.

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

<pow-20230330123728@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: built-in pow() vs. math.pow()
Date: 30 Mar 2023 11:37:56 GMT
Organization: Stefan Ram
Lines: 15
Expires: 1 Apr 2024 11:59:58 GMT
Message-ID: <pow-20230330123728@ram.dialup.fu-berlin.de>
References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 6uq956myaT7/DmpNYC7bfwxyZla2avMzTm9uMP091fC+dF
X-Copyright: (C) Copyright 2023 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Thu, 30 Mar 2023 11:37 UTC

Andreas Eisele <andreas.eisele@gmail.com> writes:
>why is it even there?

The documentation of the standard module "math" says:

|This module provides access to the mathematical functions
|defined by the C standard.

. The "pow" function of the module "builtins" is not
defined by the C standard, so it's not in "math".

The "mathematical functions" defined by C's header
<math.h> are about floating point numbers.

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

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

  copy mid

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

  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 Scott)
Newsgroups: comp.lang.python
Subject: Re: built-in pow() vs. math.pow()
Date: Thu, 30 Mar 2023 18:11:31 +0100
Lines: 27
Message-ID: <mailman.2456.1680196305.20444.python-list@python.org>
References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
<2F5598B0-14E1-44A0-9DA1-666CC846E020@barrys-emacs.org>
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\))
Content-Type: text/plain;
charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de 4LPu+MjnyZDGAQsBu4t41wPwho08ujq1QUb8bDWP7gkw==
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; 'mar': 0.07; 'cc:addr:python-list': 0.09; 'float': 0.09;
'from:addr:barry': 0.09; 'int': 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; 'from:addr:barrys-emacs.org': 0.16;
'from:name:barry scott': 0.16; 'message-id:@barrys-emacs.org':
0.16; 'rationale': 0.16; 'runtime': 0.16; 'subject:() ': 0.16;
'wrote:': 0.16; 'cc:addr:python.org': 0.20; 'maybe': 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; 'fact': 0.28; 'comment': 0.31; 'url-ip:188/8':
0.31; 'wondering': 0.31; 'header:In-Reply-To:1': 0.34; 'using':
0.37; 'this.': 0.37; 'thanks': 0.38; 'use': 0.39; 'best': 0.61;
'received:217': 0.67; 'subject:. ': 0.73; 'feature,': 0.84;
'lacks': 0.84; 'surprised': 0.84
In-Reply-To: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
X-Mailer: Apple Mail (2.3731.500.231)
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: <2F5598B0-14E1-44A0-9DA1-666CC846E020@barrys-emacs.org>
X-Mailman-Original-References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
 by: Barry Scott - Thu, 30 Mar 2023 17:11 UTC

> On 30 Mar 2023, at 10:15, 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?

Maybe math.pow() aways using IEEE 754(?) float point via the C runtime math routines.
pow() will give int answer if called with int args.

Barry

> Thanks in advance for any enlightening comment on this.
> Best regards, Andreas
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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

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

  copy mid

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

  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 Scott)
Newsgroups: comp.lang.python
Subject: Re: built-in pow() vs. math.pow()
Date: Thu, 30 Mar 2023 18:15:57 +0100
Lines: 51
Message-ID: <mailman.2458.1680196577.20444.python-list@python.org>
References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
<2F5598B0-14E1-44A0-9DA1-666CC846E020@barrys-emacs.org>
<A7BBBA19-54E1-43C0-96E0-F853EB67EF95@barrys-emacs.org>
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\))
Content-Type: text/plain;
charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de fQgRcw5cpqtiofS2Mv3fAQ/gakiICCRQplTmkI9ynqJg==
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; 'mar': 0.07; 'cc:addr:python-list': 0.09; 'float': 0.09;
'from:addr:barry': 0.09; 'int': 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;
'#include': 0.16; 'barry': 0.16; 'from:addr:barrys-emacs.org':
0.16; 'from:name:barry scott': 0.16; 'message-id:@barrys-
emacs.org': 0.16; 'rationale': 0.16; 'runtime': 0.16; 'subject:()
': 0.16; 'wrote:': 0.16; 'cc:addr:python.org': 0.20; 'maybe':
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; 'fact': 0.28; 'comment': 0.31;
'url-ip:188/8': 0.31; 'wondering': 0.31; 'header:In-Reply-To:1':
0.34; 'using': 0.37; 'this.': 0.37; 'thanks': 0.38; 'use': 0.39;
'double': 0.40; 'best': 0.61; 'received:217': 0.67; 'subject:. ':
0.73; 'feature,': 0.84; 'lacks': 0.84; 'scott': 0.84; 'surprised':
0.84; 'synopsis': 0.84
In-Reply-To: <2F5598B0-14E1-44A0-9DA1-666CC846E020@barrys-emacs.org>
X-Mailer: Apple Mail (2.3731.500.231)
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: <A7BBBA19-54E1-43C0-96E0-F853EB67EF95@barrys-emacs.org>
X-Mailman-Original-References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
<2F5598B0-14E1-44A0-9DA1-666CC846E020@barrys-emacs.org>
 by: Barry Scott - Thu, 30 Mar 2023 17:15 UTC

> On 30 Mar 2023, at 18:11, Barry Scott <barry@barrys-emacs.org> wrote:
>
>
>
>> On 30 Mar 2023, at 10:15, 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?
>
> Maybe math.pow() aways using IEEE 754(?) float point via the C runtime math routines.
> pow() will give int answer if called with int args.

And the C version of pow only supports 2 arg call.

SYNOPSIS
#include <math.h>

double
pow(double x, double y);

long double
powl(long double x, long double y);

float
powf(float x, float y);

>
> Barry
>
>
>> Thanks in advance for any enlightening comment on this.
>> Best regards, Andreas
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: roe...@roelschroeven.net (Roel Schroeven)
Newsgroups: comp.lang.python
Subject: Re: built-in pow() vs. math.pow()
Date: Thu, 30 Mar 2023 19:22:53 +0200
Lines: 21
Message-ID: <mailman.2459.1680196979.20444.python-list@python.org>
References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
<cb6c2811-1021-48ee-6fbd-74de0df6a68f@roelschroeven.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de YJZtWaV07DK8l/gwS8vSKQSdHO3SXBwhrZNcR5O0zJRQ==
Return-Path: <roel@roelschroeven.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=roelschroeven.net header.i=@roelschroeven.net
header.b=xHdrYaQz; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'argument': 0.04; '(for':
0.05; 'math': 0.05; 'attract': 0.09; 'computing': 0.09; 'docs,':
0.09; 'meant': 0.09; 'import': 0.15; '"import': 0.16; '"there':
0.16; '(even': 0.16; 'advocate': 0.16; 'arguments': 0.16;
'integer': 0.16; 'rationale': 0.16; 'received:10.202': 0.16;
'received:10.202.2': 0.16; 'received:64.147': 0.16;
'received:64.147.123': 0.16; 'received:internal': 0.16;
'received:messagingengine.com': 0.16; 'schreef': 0.16; 'subject:()
': 0.16; 'to:addr:python-list': 0.20; 'version': 0.23; 'anything':
0.25; 'do,': 0.26; 'function': 0.27; 'fact': 0.28; 'header:User-
Agent:1': 0.30; 'module': 0.31; 'wondering': 0.31; 'think': 0.32;
'but': 0.32; 'header:In-Reply-To:1': 0.34; 'this.': 0.37;
'though': 0.37; 'means': 0.38; 'use': 0.39; 'exact': 0.40; 'both':
0.40; 'potential': 0.60; 'here.': 0.61; 'experience': 0.64;
'received:64': 0.67; 'exactly': 0.68; 'subject:. ': 0.73;
'reasons': 0.84; 'converts': 0.84; 'feature,': 0.84; 'lacks':
0.84; 'surprised': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
roelschroeven.net; h=cc:content-transfer-encoding:content-type
:content-type:date:date:from:from:in-reply-to:in-reply-to
:message-id:mime-version:references:reply-to:sender:subject
:subject:to:to; s=fm1; t=1680196975; x=1680283375; bh=+qSZvV1LNp
+vFoCO5Ar36NUGzYPBb6iRI6eJ+gW5/CA=; b=xHdrYaQzWmA2dQxj6M3QoXRTkS
JoM2K69JmHc/qP0cZFQBXfIvEqidM3owbtdZu2Fw/Ie/oxssLZiY/KSUieoY0CMM
BPY96Xiw5BjrzjrJglfe9ubdGyq6UvLRcwrdhhljIoITe7IfV59HyXD1BMJmBRuv
RW+JmKsIhbxqqKbSAuBAmad2iJKgy3EAf8VzhU8o2KtHrcBBUC9l+lH7KMKoHJKs
xlc+XkP8L6oK4TicFe2LaX9M9rmB5z4aq7USb1R473MbMtcPTeJSkbzMRKs9yduQ
H6yWYjLWCJiTKtVCsJ0AAiKrnS/hkcioP3ebApZH9izt9ZAJwfuGFjUjuXLw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
messagingengine.com; h=cc:content-transfer-encoding:content-type
:content-type:date:date:feedback-id:feedback-id:from:from
:in-reply-to:in-reply-to:message-id:mime-version:references
:reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy
:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1680196975; x=
1680283375; bh=+qSZvV1LNp+vFoCO5Ar36NUGzYPBb6iRI6eJ+gW5/CA=; b=a
R7ITPWqMZwtFh5/MXWhZqaowjjFU7L/WJJeI4wRYCN14cAspvuqt7k3cQYnwZ8aJ
b7m3T1PD4K5NsFMVOMCmYXiv1uyNSdNUcIMI+RhP/UrE4RvMTBZzK/Xc+otpw2P/
4UEdW3VgX7ZMHB5B8q37mQYDkVNeKW52KT67vakd/cbdyicSJqZxrjgEE1NKEe+T
QyVzG5VNjtK9DUdGBIngLB3bTevMTI4K4nJMkPfh68fPw1xhNuWHQngPp4OebdbN
vm+LQCfyTn/0D+kGOPDCOSmIQeku+wfcoZXRuyDa/Hjqz6lPMMIj1V2cuheJgNCk
ToXh4cRU3Q+6+GSIsDZnw==
X-ME-Sender: <xms:b8UlZEg0KKBH2fsLVBNfnHAwKcb2Y6jzYnezCy0GvWMUkolAkM8iVg>
<xme:b8UlZNAObTrc-bRBfSEqAk7L4QppPbo4Dq6oCiDarhi9_5cUSBMXDrdjSQLMrFYKm
9tb8Wy2xapL>
X-ME-Received: <xmr:b8UlZMGG3tqa-EDX6yETUeZ_jLLvWO1GqPxb8A9BrUlj4BZSYi83YatjN7vedKPUg28FB5QLLyD3WYqV3sOBk_xw-iOTFGc>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdehledgvddtucetufdoteggodetrfdotf
fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
uceurghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtje
ertddtfeejnecuhfhrohhmpeftohgvlhcuufgthhhrohgvvhgvnhcuoehrohgvlhesrhho
vghlshgthhhrohgvvhgvnhdrnhgvtheqnecuggftrfgrthhtvghrnhepteeujefftedufe
eiteevhffgtedvgeeijeekjeeutdevhfevvdduuedtteetudeinecuvehluhhsthgvrhfu
ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhhovghlsehrohgvlhhstghhrh
hovghvvghnrdhnvght
X-ME-Proxy: <xmx:b8UlZFQyoPrOkjui7BnqM4n4eyV-srJ1eLuXPNvAyIkauyK2d7zzpQ>
<xmx:b8UlZByqIB3e20SHyN7bxAjgxvVv_ft7e30YbSpwIL7aQdripm9kNw>
<xmx:b8UlZD4ydFqoNlWJkttetZIlC_K8gKqK91bQYW8-SVZ9ihLO2J2IqA>
<xmx:b8UlZKtLFgipDszA5SUhihDbE8VMLFWubRefzky5e6fQX90LPwZdaw>
Feedback-ID: i8e5b41ae:Fastmail
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.9.1
Content-Language: en-GB
In-Reply-To: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
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: <cb6c2811-1021-48ee-6fbd-74de0df6a68f@roelschroeven.net>
X-Mailman-Original-References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
 by: Roel Schroeven - Thu, 30 Mar 2023 17:22 UTC

Andreas Eisele schreef op 30/03/2023 om 11:15:
> 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?
According to the docs, "Unlike the built-in ** operator, math.pow()
converts both its arguments to type float. Use ** or the built-in pow()
function for computing exact integer powers." I think that means that
math.pow() is more meant to work with floats, while the built-in is more
meant for integers (even though the built-in works with floats just fine).

In any case, I would strongly advocate against "from math import *" (not
just for math but for any module really). One of the reasons is the
potential for name conflicts, which is exactly what you experience here.

Either import the things you need explicitly: "from math import sin,
cos, exp" (for example).
Or a plain import: "import math" combined with "math.sin", "math.cos".
Or use an abbreviation: "import math as m" combined with "m.sin", "m.cos".

--
"There is no cause so noble that it will not attract fuggheads."
-- Larry Niven

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

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: lis...@tompassin.net (Thomas Passin)
Newsgroups: comp.lang.python
Subject: Re: built-in pow() vs. math.pow()
Date: Thu, 30 Mar 2023 13:25:30 -0400
Lines: 6
Message-ID: <mailman.2460.1680197142.20444.python-list@python.org>
References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
<61154096-2d94-1ea7-b5de-54db14719bce@tompassin.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de j4igjDEkDtW22OtvmgcTvQVJeZLf6H89fKBA8lSssJIg==
Return-Path: <list1@tompassin.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=tompassin.net header.i=@tompassin.net header.b=UvFjCTup;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.016
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'argument': 0.04; 'math':
0.05; 'import': 0.15; '"import': 0.16; '5:15': 0.16; 'question,':
0.16; 'rationale': 0.16; 'received:10.0.0': 0.16;
'received:64.90': 0.16; 'received:64.90.62': 0.16;
'received:64.90.62.162': 0.16; 'received:dreamhost.com': 0.16;
'subject:() ': 0.16; 'wrote:': 0.16; 'to:addr:python-list': 0.20;
'version': 0.23; 'anything': 0.25; 'do,': 0.26; 'function': 0.27;
'fact': 0.28; 'header:User-Agent:1': 0.30; 'am,': 0.31;
'wondering': 0.31; 'received:10.0': 0.32;
'received:mailchannels.net': 0.32;
'received:relay.mailchannels.net': 0.32; 'but': 0.32; 'header:In-
Reply-To:1': 0.34; "it's": 0.37; 'this.': 0.37; 'use': 0.39;
'your': 0.64; 'header:Received:6': 0.67; 'received:64': 0.67;
'subject:. ': 0.73; 'need.': 0.84; 'feature,': 0.84; 'lacks':
0.84; 'surprised': 0.84
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1680197132; a=rsa-sha256;
cv=none;
b=qTbFj6IsIPOrmF2ZsBYysXtIL0AVbtHwgBk0OwOOM4uA9/tcQ3DzpHexohwSD9gEqIDkxG
IDIZVNwkotCPN08ncJKCDgOb2dRdfclXRdAbYMMnsPjhMdPqKwPlsXbuLdJr6GYZS2jVbZ
u2N1uje237sdiIZb0TUVd6xpIvU6vtyFZwK9hEaxtlbfxDveXqqIEf6BiwncGJXzs8rqSV
v067L59emRCd/4wOB1Tadsw1AtJspaz8L6FgnQRG1j8Bn1Ui1sHKtuzrWdOvl1mI8irXvV
bxPmTTC09JXh4/KjpVAQLFw1Ib5iz3ESYplsP5sL6UHT31BPp8kg8g+nrPVfIg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1680197131;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=D2CSBkhG8KzhBquMDTpIz53dyjHFvINZe6+QU0Ou9Cw=;
b=ozS7nYfaW4JvaBew9+3qVIFACCQx03SMOX8Wyoj+6tWNYJpkK2MrSYPojkaJvr5c7nNNMX
ZU1XJrGenUylYEUXWBgDwz6En0IvXgT1jMLVKZVCU9ULFKL9PBo91gHR+5ZqsBEELyLhMZ
X2T3F+dmsNX12wRTMqGpyRZCRik8GKltSdkQot2dqb16jiIYLNHBVGomlAqJYSBfPW2jdg
qUKw4nZkvaY3szC89D2bmtBCuV/uKTXpB4TVgSRwSkyHHVMDrmyik/JLZsR3yjxQ14ronN
i2ZzpAmKHf9DiAXtjl10/DzcJmu25ZZuWuA1P7ZOyIPZL1DLSsLnJrmyy+Qccw==
ARC-Authentication-Results: i=1; rspamd-5468d68f6d-j4xmp;
auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|tpassin@tompassin.net
X-MailChannels-Auth-Id: dreamhost
X-Thread-Shade: 3d1efe23746d0c80_1680197132202_1045130407
X-MC-Loop-Signature: 1680197132202:2687693577
X-MC-Ingress-Time: 1680197132202
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1680197131;
bh=D2CSBkhG8KzhBquMDTpIz53dyjHFvINZe6+QU0Ou9Cw=;
h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding;
b=UvFjCTupzZ8XGB1K0RaLU5rjFxFrL9LYzK4zD+HjpJ/3AcOKXB4iqqiL1bfuy75Fy
7JTJsd0Z1Uer2XRj+M5QSOuRAl0WbNA171HgdbYpbJDe6m0yjkMwUke/dn19ms9aVG
1rbN81NRzKkOsOWhcEIwoHTf8PfoW0KqNnHIGX+miLLzdsAsQeTt0GstkKDTzfeiSC
2aS8qOMPDf47/WIwACOXfIIgBEz1EwhPuaEHgx6QxAkjkBWHNltuGYKL/O0cjAJmp/
TMOxm6r93WZA0CAJTmwZpS55M8rdHcFRExeZhIbUgitKKGrlad94UJ0HEasmB78Drw
v1igHn1xAxxCQ==
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Content-Language: en-US
In-Reply-To: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
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: <61154096-2d94-1ea7-b5de-54db14719bce@tompassin.net>
X-Mailman-Original-References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
 by: Thomas Passin - Thu, 30 Mar 2023 17:25 UTC

On 3/30/2023 5:15 AM, Andreas Eisele 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?

Not an answer to your question, but it's better not to use "import *".
It's usually better to import just the names you actually need.

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

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: grant.b....@gmail.com (Grant Edwards)
Newsgroups: comp.lang.python
Subject: Re: built-in pow() vs. math.pow()
Date: Thu, 30 Mar 2023 12:15:03 -0700 (PDT)
Lines: 21
Message-ID: <mailman.2462.1680203707.20444.python-list@python.org>
References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
<61154096-2d94-1ea7-b5de-54db14719bce@tompassin.net>
<6425dfb7.920a0220.dcc7b.045d@mx.google.com>
X-Trace: news.uni-berlin.de PP9+58zhOqM85y9CipY7HgvABAxZglxx492HIIuJr1bg==
Return-Path: <grant.b.edwards@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=dvpl2wmI;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.042
X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'frequent': 0.05; 'math':
0.05; 'fact,': 0.09; 'import': 0.15; '"import': 0.16; '5:15':
0.16; 'from:addr:grant.b.edwards': 0.16; 'from:name:grant
edwards': 0.16; 'question,': 0.16; 'subject:() ': 0.16; 'wrote:':
0.16; 'python': 0.16; 'grant': 0.17; 'to:addr:python-list': 0.20;
'seems': 0.26; 'function': 0.27; 'header:User-Agent:1': 0.30;
'am,': 0.31; 'think': 0.32; 'official': 0.32; 'assume': 0.32;
'but': 0.32; 'received:google.com': 0.34; 'received:209.85.166':
0.35; 'from:addr:gmail.com': 0.35; 'people': 0.36; 'source': 0.36;
"it's": 0.37; 'received:209.85': 0.37; 'received:209': 0.39;
'use': 0.39; 'your': 0.64; 'subject:. ': 0.73; 'out.': 0.80;
'leads': 0.81; 'need.': 0.84; 'feature,': 0.84; 'lacks': 0.84;
'surprised': 0.84; 'when,': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112; t=1680203704; x=1682795704;
h=to:user-agent:references:subject:from:date:message-id:from:to:cc
:subject:date:message-id:reply-to;
bh=Z9RPUO5Ps9cMUjpJoVLYEsQh4Auzfohnw3/ew6lMDwc=;
b=dvpl2wmItjzHMhckElQ/qdRyQgg79ixInUF3zHsQpyn23yZmPcCNZK49OZVPP0662D
mHXeIEuCRrHxYYZm1M1Y85odWF3/bZdNGv50PzOdVg7DjZFVk3Gw8I8+o9U+f5yoJ4UX
8buArWTs7yK7EE/OXYHtV3O/77Xnh45OU3f0RnOhwduaQugJudmHmmxgajMMfKU+HkvU
UTLfutC/lqWJ8xvgVlHX2Jn9ByXiErQv7BVLHEwpDqvpUEPEkRpKxCVIgaLpmf0DUL0d
jIVcW+fOc88X/1NCcDOQ5aaRI5E8hTQsPor3CdZdlrSceE2acBzouCT15Mi0PDp/YKSN
w22Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112; t=1680203704; x=1682795704;
h=to:user-agent:references:subject:from:date:message-id
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=Z9RPUO5Ps9cMUjpJoVLYEsQh4Auzfohnw3/ew6lMDwc=;
b=twX6CKfWC5B5iZKxzHm9d5gsNe7Kh9tLal6BtM2+2RypKAHKhM0Sb25YoRfqWkEBEN
7k2nbI9n6962uf0icGVzlQrLTG6z0KV8zHzSr9e27zjzG7SmkK6JIkwjfQcgK3WwInzW
Y22LK2v4jLQXZ5J8umt53QAnXQZWS/RGSEuv/7oghqe76vTJMHAjpdxKHF7BPFfI9Bry
kX940iusyU6t6adUywP6lqIkIkI8NVrgOJJgXj7l0+JqtHq4gWcogQ65MSCnNtl4PY2z
Lx+0SacBo9wBjQ23bjlOWLS7xpWxOAuXFz8dVa+A2fqAb49RW/joNH4LLnGG5QMjGVNM
2qjw==
X-Gm-Message-State: AAQBX9febEDuRaUHQgdyNXlGTDo5oN3fl/5iWUqNRSlT9GBA/+/mgSaC
qPBqQhEq+iCuiD2xdLFgF9F2nIK5jeo=
X-Google-Smtp-Source: AKy350btHOZvJh77DYpLp8K1G4q51b3hQPKQ56yqCE/Fg2+hPOxG1HH4JqVBVo+hKW9osjuKjAnC1g==
X-Received: by 2002:a92:c90a:0:b0:325:ea77:e882 with SMTP id
t10-20020a92c90a000000b00325ea77e882mr15561190ilp.29.1680203704225;
Thu, 30 Mar 2023 12:15:04 -0700 (PDT)
User-Agent: slrn/1.0.3 (Linux)
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: <6425dfb7.920a0220.dcc7b.045d@mx.google.com>
X-Mailman-Original-References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
<61154096-2d94-1ea7-b5de-54db14719bce@tompassin.net>
 by: Grant Edwards - Thu, 30 Mar 2023 19:15 UTC

On 2023-03-30, Thomas Passin <list1@tompassin.net> wrote:
> On 3/30/2023 5:15 AM, Andreas Eisele wrote:

>> [...] 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. [...]
>
> Not an answer to your question, but it's better not to use "import *".
> It's usually better to import just the names you actually need.

Or to imporot math and then use math.pow().

Unfortunately, the official Python documentation always seems to
assume you do "from <whatever> import *". I think that leads people to
believe it's a good practice when, in fact, it's a frequent source of
trouble as the OP found out.

--
Grant

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

<etpb2i5a31c6q0nlsa2254hc10f76j41im@4ax.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 30 Mar 2023 19:49:55 +0000
From: wlfr...@ix.netcom.com (Dennis Lee Bieber)
Newsgroups: comp.lang.python
Subject: Re: built-in pow() vs. math.pow()
Date: Thu, 30 Mar 2023 15:49:54 -0400
Organization: IISS Elusive Unicorn
Message-ID: <etpb2i5a31c6q0nlsa2254hc10f76j41im@4ax.com>
References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com> <cb6c2811-1021-48ee-6fbd-74de0df6a68f@roelschroeven.net> <mailman.2459.1680196979.20444.python-list@python.org>
User-Agent: ForteAgent/8.00.32.1272
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 17
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-nQoJxsQgJn9qMp+wl+4hNVwqaTX/K7jV7S35XjEk1zMNNi/gKsF2QZGTxpPaX4c8DAOD0RYtfCUdVVr!827fpg+vlnlqDAeE5GLcWpn+FkAEirckxtq1yWu7aBhXMX49MBNv2djBKxfnUcRwfvIg08Ny
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Dennis Lee Bieber - Thu, 30 Mar 2023 19:49 UTC

On Thu, 30 Mar 2023 19:22:53 +0200, Roel Schroeven <roel@roelschroeven.net>
declaimed the following:

>Either import the things you need explicitly: "from math import sin,
>cos, exp" (for example).
>Or a plain import: "import math" combined with "math.sin", "math.cos".
>Or use an abbreviation: "import math as m" combined with "m.sin", "m.cos".

Or, for this particular example of not wanting math.pow...

>>> from math import *
>>> pow(3, 4)
81.0
>>> del pow
>>> pow(3, 4)
81
>>>

RE: built-in pow() vs. math.pow()

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From:
Newsgroups: comp.lang.python
Subject: RE: built-in pow() vs. math.pow()
Date: Thu, 30 Mar 2023 17:02:18 -0400
Lines: 61
Message-ID: <mailman.2463.1680210143.20444.python-list@python.org>
References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
<00af01d9634a$ea4d3b40$bee7b1c0$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de Ps8fWCik+pmbqvLd888lUAQfSVhcKk+3IizYlmzuk6HA==
Return-Path: <avi.e.gross@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=N69/QrHk;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.023
X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'argument': 0.04; 'math':
0.05; 'variable': 0.05; '2023': 0.07; 'explicitly': 0.07;
'blocking': 0.09; 'deeper': 0.09; 'identical': 0.09; 'namespace':
0.09; 'received:108': 0.09; 'import': 0.15; 'url:mailman': 0.15;
'5:16': 0.16; 'feature.': 0.16; 'importing': 0.16; 'rationale':
0.16; 'received:209.85.217': 0.16; 'subject:() ': 0.16;
'variables,': 0.16; 'python': 0.16; 'message-id:@gmail.com': 0.18;
'bug': 0.19; 'it?': 0.19; 'name.': 0.19; 'to:addr:python-list':
0.20; 'language': 0.21; 'version': 0.23; '(and': 0.25; 'anything':
0.25; 'skip:- 10': 0.25; 'url-ip:188.166.95.178/32': 0.25; 'url-
ip:188.166.95/24': 0.25; 'url:listinfo': 0.25; 'url-
ip:188.166/16': 0.25; 'do,': 0.26; 'function': 0.27; 'fact': 0.28;
'version.': 0.28; 'asked': 0.29; 'comment': 0.31; 'module': 0.31;
'url-ip:188/8': 0.31; 'wondering': 0.31; 'question': 0.32;
'python-list': 0.32; 'there': 0.33; 'march': 0.33; 'package':
0.34; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'people': 0.36; 'received:209.85':
0.37; 'others': 0.37; 'this.': 0.37; 'thanks': 0.38;
'received:209': 0.39; 'handle': 0.39; 'use': 0.39; 'base': 0.40;
'something': 0.40; 'want': 0.40; 'view': 0.60; 'best': 0.61;
'method': 0.61; 'above': 0.62; 'from:': 0.62; 'to:': 0.62; 'seen':
0.62; 'reasonable': 0.62; 'simply': 0.63; 'copy': 0.63; 'your':
0.64; 'entire': 0.67; 'rules': 0.70; 'preferences': 0.73;
'subject:. ': 0.73; 'sent:': 0.78; 'waste': 0.81; 'powerful':
0.84; 'reasons': 0.84; 'feature,': 0.84; 'lacks': 0.84;
'provides.': 0.84; 'scope': 0.84; 'surprised': 0.84; 'tune': 0.84;
'vs.': 0.84; 'turned': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112; t=1680210141;
h=thread-index:content-language:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:from:to:cc:subject:date:message-id:reply-to;
bh=KY/UL5YhkzkqTj+dSmGH7IR24Yj3s6xOVoEllo3pRd4=;
b=N69/QrHkP96x7CzTgO9j8HEO1evaDnZOCw1QP2/8CcFug77xbeBO2v62Yk0M0GX/0y
kOa95ThqqtZH4XFX/o5/pQYXURspD6d6We1FrhQqrgZYdzcmZj5kzpCtpVsuMUe94s3G
lRXKqtUfVIK6lijubV1NW2qr71qPjlIfpSEyq9eHuZ+SuSTWdyIO6VZr2qDgq/P/dpDb
1cPKCaGyfJXO0qXJCaka5wVzCn4nVnOj9BJZwmugU5ATAtW6dsvG56uzlL3rS4sLQqxR
ThqUk22E9nipHX80kLgtVRAap6yL5PNQtiDx4DaoytgipiYlXA4fYg4V7TgLjzuwvYa5
dC1Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112; t=1680210141;
h=thread-index:content-language:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=KY/UL5YhkzkqTj+dSmGH7IR24Yj3s6xOVoEllo3pRd4=;
b=V3nEFe6k8x9GeEmKuBDGMy450AVC7hdDifHRKtMFy9BzZxae3hAW5n/y7BnUe22Z2f
WGEgfE14zag/cYYT/4lt6kMaafMCkoS6zlYInOApEAFlFP0TgqGIYygQ5nMox9CaiBQV
nc7x+v1K9XCQ1LrTwvnClHIwvf/ybCm81RjgY6qGE/PCXjEdeJ7MoVesf6W/uTI59Wv6
emWnEtsDIW/tlWbJ8WFjvIe4bbIErJjMRfQ5RYMCVppNNLsYoh3gki57sn7AHgUa7Z0X
P/83foQd8FOwppqUT7JuDz+pxuzJ0JsQspAolU1DxR8MO7DQ4pGWvnZe3FrVrQqa3bky
kEWQ==
X-Gm-Message-State: AAQBX9eIHbYAzfibvUJ2zacOuMacOZlMOq7KBQil6Vs6auj+lOMDIqq6
sWWCEVf1L9nLeZ+TmXjG2eLJ9J3VPQ4=
X-Google-Smtp-Source: AKy350Y4hqUz6U9oMs7P5a90ITQ7/quMz1smwLsYHESqVqyGye55UFFxA1uNWjV7+kO2ryxt43j0sg==
X-Received: by 2002:a67:cf06:0:b0:425:fce2:d1ac with SMTP id
y6-20020a67cf06000000b00425fce2d1acmr9845118vsl.5.1680210140758;
Thu, 30 Mar 2023 14:02:20 -0700 (PDT)
In-Reply-To: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-us
Thread-Index: AQGYptlPKm9yY5em5yQ0K5djEqR7I6+VRMiQ
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: <00af01d9634a$ea4d3b40$bee7b1c0$@gmail.com>
X-Mailman-Original-References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
 by: - Thu, 30 Mar 2023 21:02 UTC

Some questions are more reasonable than others.

If the version of a function used in a package were IDENTICAL to the
built-in, then why have it?

There are many possible reasons a package may tune a function for their own
preferences or re-use a name that ends up blocking the view of another name.

The bottom line is if you do not want the other one, then don't ask for it
by not importing the entire module into your namespace or by explicitly
asking for the base function in the ways python provides.

Others have replied about differences in various implementations of pow()
and reiterated my point above that if you want a specific function instance,
it is your responsibility to make sure you get it.

One method I would mention that I have not seen is to copy pow() to your own
name before importing other things. Something like:

pow3 = pow
import ...

Then use the new name.

Or import all of math (despite advice not to) and then make pow3 a synonym
for the base version.

Most people most of the time will want a small and fast function that does
what they asked for and does not waste time looking for an optional third
argument and doing something additional. Would you be satisfied if
math::pow() simply checked for a third argument and turned around and called
base::pow() to handle it?

A deeper question I can appreciate is wondering if it is a bug or feature
that python (and many other languages) allow results where you can hide a
variable or function name. I call it a feature. As with all such variables,
scope rules and other such things apply and make the language powerful and
sometimes a tad dangerous.

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On
Behalf Of Andreas Eisele
Sent: Thursday, March 30, 2023 5:16 AM
To: python-list@python.org
Subject: built-in pow() vs. math.pow()

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?
Thanks in advance for any enlightening comment on this.
Best regards, Andreas
--
https://mail.python.org/mailman/listinfo/python-list

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

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: oscar.j....@gmail.com (Oscar Benjamin)
Newsgroups: comp.lang.python
Subject: Re: built-in pow() vs. math.pow()
Date: Thu, 30 Mar 2023 22:11:33 +0100
Lines: 19
Message-ID: <mailman.2464.1680210707.20444.python-list@python.org>
References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
<CAHVvXxRG7XthrSXhYst3YkW01uUnCZuH9cj2puV_P_4GHW-2sw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de JdteEeHau3sKWdNTqDh3jwQVVPtUqcI10IacUtrjkgxw==
Return-Path: <oscar.j.benjamin@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=OMcoLvYF;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.022
X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'argument': 0.04; 'math':
0.05; '2023': 0.07; 'mar': 0.07; 'floating': 0.09; 'import': 0.15;
'integer': 0.16; 'rationale': 0.16; 'subject:() ': 0.16; 'wrote:':
0.16; 'thu,': 0.19; 'to:addr:python-list': 0.20; 'version': 0.23;
'anything': 0.25; 'do,': 0.26; 'function': 0.27; 'fact': 0.28;
'wondering': 0.31; 'message-id:@mail.gmail.com': 0.32; 'header:In-
Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'received:209.85': 0.37; 'this.':
0.37; 'received:209': 0.39; 'received:209.85.208': 0.39; 'use':
0.39; 'want': 0.40; 'similar': 0.65; 'named': 0.65; 'cost': 0.69;
'subject:. ': 0.73; 'feature,': 0.84; 'lacks': 0.84; 'oscar':
0.84; 'surprised': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112; t=1680210705;
h=content-transfer-encoding:to:subject:message-id:date:from
:in-reply-to:references:mime-version:from:to:cc:subject:date
:message-id:reply-to;
bh=2B+Cxjhx/H3xETfOH8C+Nx22Xhp4ifLZ7CGumnBpucQ=;
b=OMcoLvYF8R7r0fAM38l2Lh6zo/3U4pi36hruq2Wu4gisX1t4HElqB36kXLpRx4f+gM
Cb2Ll6xeNSxONYkzIiZtQrsST2R++nw7mdyU5gv/oZZr4VmMQBfTMafGtEe2Oj7Hxvso
NMDHNn23iydwgr/Ta92oe0N6evVG+N1eCcp58YbeMMsNiw9+dNQH0cB4GKQIWmyjVKuJ
LVq5lDZ444sTUiUPFvZ+jN6jIYf5YFTVQYXiHJ7KuaL9RdI+werR92DS+C0S7pu3AeSq
5QwLwF+IeBVxeaeqFaLRo+m5hrG2duzlaKl1tYsoFet8tu0iVgZQ0U56ktGK90I+DoQJ
LAmQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112; t=1680210705;
h=content-transfer-encoding:to:subject:message-id:date:from
:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
:subject:date:message-id:reply-to;
bh=2B+Cxjhx/H3xETfOH8C+Nx22Xhp4ifLZ7CGumnBpucQ=;
b=jcxIDUc7uPpeew5+dpyzqlWoDDrIt0JcyVoCWwkC8+YlGfdJXZg6z/bmPuM4un14D8
KfNiGhxQaevL3YBt9SeYc9A2wV8Sv12s0gzOJPnKyiTZpxFPT5yzs/J2AI5Iu55JCYGy
e3/rJaE9XTo5KreMlDpIxpKWOTfm+7rBSueVaJASuXA/C9VNQ8K2A6rArWBtTCCXqsav
PJ8cUc6Ul/FN9v7KUvff0/SUo9fxTaJuYROBqGEpeb2gC1TGiyrfzugvb6IY89uRfqYi
uVVnuueedo0KRUgUYZOCfWLN4dlfac8OjFyX1hRlp16t0UM/IefDGxEm3LIPC6FuOjmI
wumw==
X-Gm-Message-State: AAQBX9fntYMPtrgYFP5zaUzLGSStUbwCBfMre6XiB3R9BXIV8HYrIc7H
HxL6InGupSY/8ZdOOxQaTkrDroMh8qrsxEy8PArdVnNR
X-Google-Smtp-Source: AKy350ZCH5VK6tUXbn2I4hg0zIsf3haXaIJX2+QZ862Lk8qEO+7tVDplnKKlCv9pYqU3yVgeMmq4ZdBQiq1ZXE+hKSw=
X-Received: by 2002:a2e:a307:0:b0:2a6:18c0:2b44 with SMTP id
l7-20020a2ea307000000b002a618c02b44mr1198721lje.0.1680210704892; Thu, 30 Mar
2023 14:11:44 -0700 (PDT)
In-Reply-To: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
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: <CAHVvXxRG7XthrSXhYst3YkW01uUnCZuH9cj2puV_P_4GHW-2sw@mail.gmail.com>
X-Mailman-Original-References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
 by: Oscar Benjamin - Thu, 30 Mar 2023 21:11 UTC

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.

--
Oscar

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

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: built-in pow() vs. math.pow()
Date: Fri, 31 Mar 2023 08:27:39 +1100
Lines: 25
Message-ID: <mailman.2465.1680211672.20444.python-list@python.org>
References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
<CAHVvXxRG7XthrSXhYst3YkW01uUnCZuH9cj2puV_P_4GHW-2sw@mail.gmail.com>
<CAPTjJmqALCzLVLjq_rpbEYRZ0BEodWtQpTA_tFAuVoVaahDhtQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de OUs9o68o1SHhVrdnnYPZ8wZLFf2wewQlemYcoB/XinUA==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=CeqG4Rnf;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.012
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'argument': 0.04; 'math':
0.05; '2023': 0.07; 'mar': 0.07; 'floating': 0.09; 'import': 0.15;
'chrisa': 0.16; 'floats.': 0.16; 'from:addr:rosuav': 0.16;
'from:name:chris angelico': 0.16; 'integer': 0.16; 'rationale':
0.16; 'subject:() ': 0.16; 'wrote:': 0.16; 'thu,': 0.19; 'to:addr
:python-list': 0.20; 'fri,': 0.22; 'version': 0.23; 'anything':
0.25; 'do,': 0.26; 'function': 0.27; 'fact': 0.28; 'wondering':
0.31; 'message-id:@mail.gmail.com': 0.32; 'header:In-Reply-To:1':
0.34; 'received:google.com': 0.34; 'from:addr:gmail.com': 0.35;
"it's": 0.37; 'received:209.85': 0.37; 'this.': 0.37;
'received:209': 0.39; 'received:209.85.208': 0.39; 'use': 0.39;
'want': 0.40; 'should': 0.40; 'similar': 0.65; 'named': 0.65;
'cost': 0.69; 'strong': 0.69; 'subject:. ': 0.73; 'feature,':
0.84; 'lacks': 0.84; 'oscar': 0.84; 'surprised': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112; t=1680211670;
h=content-transfer-encoding:to:subject:message-id:date:from
:in-reply-to:references:mime-version:from:to:cc:subject:date
:message-id:reply-to;
bh=qOTU2P88FC0XwU0lBCiX//DMGopOR+GxXM0842kYm+g=;
b=CeqG4Rnf6Cf5wsPdC235fnCEeDpb1Yx5mrdmmDihcqd47i6jhHrDRQFZUXNLMAAxSz
oAEB05AOoDQip4cWGNE4fANSUTmXlCY3uXRWuZFd8ZbgTv4xCLMy/2p4NwheIq0745NN
8MDwDYaT9o5uB9NjYpbewNJ9qdhpSiLy1gbQbspRIK0/yh1+wUD9ojfA0x7DmIFt+kIX
wrTAmhZeryC0f4jK3QfT7szlshRxKosrVWAeSysjmYjDoLO2xqieTKeB3rkgm/yu2ciY
lOmd6XTY1GFUUzyhm7rCaMdw39Yzu6rxZaHn6GHGgS+hQlsxD5AI6e5r8I90W4RAy0V8
Fmlg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112; t=1680211670;
h=content-transfer-encoding:to:subject:message-id:date:from
:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
:subject:date:message-id:reply-to;
bh=qOTU2P88FC0XwU0lBCiX//DMGopOR+GxXM0842kYm+g=;
b=iaMgk0vTy+ZxTnimZENf61QiC/M7xmAjPoG35RMOgj+3GHVy/k+8AHb2zepfqBVP90
vLRFeV5+d4tP6j8gSLoQj958yXrgvLSQWOJv1ODY5Ar2mkqkItjCKR3yQaRAcLGD8sWm
6ZurYwCKXgCLbb/9f9I1W1yHcspdQm1CSnczbqLdbQy9s0h8GvVrGgVHuZ8pR4IYyIci
qlWEWSYrz5/cfsWHkY9VJeMc9fJqaepOYpcDtKAdALzdCB9THY6wmYbi7XfAi7YiMo6g
SsdOyqK66JGt+dvMECJTsfhjP6FyeOcsn1OEj90pugRJa2PLxQEN8tLw/mG2rcZRzo9V
jNSA==
X-Gm-Message-State: AAQBX9fWIMG6NnpuKYLrU4NoM55Ingc9MdsP/DvJbMsJr0RwFQWrjoIr
zU1omowlTrnqNUf4eKCMXjBIsYIrUNF14kfpPE76kRWz
X-Google-Smtp-Source: AKy350YHTo2q0m4GLjDjcv9x8QpmCbcfPi29iPRMwSEAKSviiQj7gAjTWfXTDNB0o6xoDLS399c/2bHpVfr5WKAvSV8=
X-Received: by 2002:a50:9f6f:0:b0:4fb:2593:846 with SMTP id
b102-20020a509f6f000000b004fb25930846mr11593033edf.3.1680211670615; Thu, 30
Mar 2023 14:27:50 -0700 (PDT)
In-Reply-To: <CAHVvXxRG7XthrSXhYst3YkW01uUnCZuH9cj2puV_P_4GHW-2sw@mail.gmail.com>
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: <CAPTjJmqALCzLVLjq_rpbEYRZ0BEodWtQpTA_tFAuVoVaahDhtQ@mail.gmail.com>
X-Mailman-Original-References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
<CAHVvXxRG7XthrSXhYst3YkW01uUnCZuH9cj2puV_P_4GHW-2sw@mail.gmail.com>
 by: Chris Angelico - Thu, 30 Mar 2023 21:27 UTC

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.

ChrisA

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

<f1b36be4-55d9-4aeb-b0b6-90ba7144b19en@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a05:6214:534a:b0:56b:ed36:ffb with SMTP id kv10-20020a056214534a00b0056bed360ffbmr3086087qvb.1.1680362207310;
Sat, 01 Apr 2023 08:16:47 -0700 (PDT)
X-Received: by 2002:aca:3cc6:0:b0:386:e33f:84f2 with SMTP id
j189-20020aca3cc6000000b00386e33f84f2mr8188012oia.1.1680362206990; Sat, 01
Apr 2023 08:16:46 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Sat, 1 Apr 2023 08:16:46 -0700 (PDT)
In-Reply-To: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=158.169.150.17; posting-account=jEtcCwoAAADNlDXdwYCl7UKBmA9fHVUA
NNTP-Posting-Host: 158.169.150.17
References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f1b36be4-55d9-4aeb-b0b6-90ba7144b19en@googlegroups.com>
Subject: Re: built-in pow() vs. math.pow()
From: andreas....@gmail.com (Andreas Eisele)
Injection-Date: Sat, 01 Apr 2023 15:16:47 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2864
 by: Andreas Eisele - Sat, 1 Apr 2023 15:16 UTC

Andreas Eisele schrieb am Donnerstag, 30. März 2023 um 11:16:02 UTC+2:
> 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?
> Thanks in advance for any enlightening comment on this.
> Best regards, Andreas

Thanks a lot to all of you for the insightful replies!
I now understand why math.pow() behaves the way it does and whoever tells me I should have read the doc of the math module before using it is 100% on point.
BTW, there is another difference: built-in pow() deals with complex arguments, while functions in math won't accept them at all.
I also agree with the warning that importing * from any module is generally a bad idea, and I normally would not do it. But here I had written a little tool that evaluates an expression given on the command line, and in this case having math functions available without further ado is very convenient, so it seemed appropriate to make an exeption to this rule.
I ended up assigning the built-in pow function to a different name before importing the math module, which is a good way to keep both variants accessible.
Best regards, and thanks again, Andreas

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

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: 2QdxY4Rz...@potatochowder.com
Newsgroups: comp.lang.python
Subject: Re: built-in pow() vs. math.pow()
Date: Mon, 3 Apr 2023 15:49:45 -0400
Lines: 7
Message-ID: <mailman.2538.1680551396.20444.python-list@python.org>
References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
<f1b36be4-55d9-4aeb-b0b6-90ba7144b19en@googlegroups.com>
<ZCst2Sqe1eK21LHT@anomaly>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.uni-berlin.de BAuUYLMgDE5AVX3sEJZwpAbb/8vjohxEW+GQcDDv3CVw==
Return-Path: <2QdxY4RzWzUUiLuE@potatochowder.com>
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.004
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'math': 0.05; '-0700,':
0.09; 'received:78': 0.09; 'from:addr:2qdxy4rzwzuuilue': 0.16;
'from:addr:potatochowder.com': 0.16; 'received:136.243': 0.16;
'received:78.46': 0.16; 'received:78.46.172': 0.16;
'received:www458.your-server.de': 0.16; 'received:your-server.de':
0.16; 'subject:() ': 0.16; 'wrote:': 0.16; 'to:addr:python-list':
0.20; 'received:de': 0.23; 'received:136': 0.32; 'there': 0.33;
'header:In-Reply-To:1': 0.34; 'complex': 0.35; 'functions': 0.36;
'accept': 0.67; 'subject:. ': 0.73
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <f1b36be4-55d9-4aeb-b0b6-90ba7144b19en@googlegroups.com>
X-Authenticated-Sender: 2QdxY4RzWzUUiLuE@potatochowder.com
X-Virus-Scanned: Clear (ClamAV 0.103.8/26864/Mon Apr 3 09:23:42 2023)
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: <ZCst2Sqe1eK21LHT@anomaly>
X-Mailman-Original-References: <831c6c1c-c4ee-4a59-bba8-d8c2df0e982cn@googlegroups.com>
<f1b36be4-55d9-4aeb-b0b6-90ba7144b19en@googlegroups.com>
 by: 2QdxY4Rz...@potatochowder.com - Mon, 3 Apr 2023 19:49 UTC

On 2023-04-01 at 08:16:46 -0700,
Andreas Eisele <andreas.eisele@gmail.com> wrote:

> BTW, there is another difference: built-in pow() deals with complex
> arguments, while functions in math won't accept them at all.

See also <https://docs.python.org/3/library/cmath.html>.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor