Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Terry Reedy Newsgroups: comp.lang.python Subject: Re: Question about math.pi is mutable Date: Fri, 6 Nov 2015 20:49:17 -0500 Lines: 36 Message-ID: References: <1590467.kktH0DaBsW@PointedEars.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de sVEXxHEMbPECWWE9J+dauAu9xR5aok/f45pt5+JXhLjQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'subject:Question': 0.05; 'variable,': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'jan': 0.11; 'discussions': 0.15; 'variables': 0.15; 'constants': 0.16; 'function.)': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'wrote:': 0.16; 'attribute': 0.18; 'math': 0.20; 'exceptions': 0.22; 'import': 0.24; 'implemented': 0.24; 'written': 0.24; 'header:In-Reply-To:1': 0.24; 'module': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'mostly': 0.27; 'not.': 0.27; 'mathematical': 0.27; 'function': 0.28; "skip:' 10": 0.28; '(perhaps': 0.29; 'attempting': 0.29; 'print': 0.30; 'another': 0.32; 'authors': 0.35; 'but': 0.36; 'should': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'does': 0.39; 'to:addr:python.org': 0.40; 'skip:n 10': 0.62; 'thomas': 0.63; 'costly': 0.84; 'presumably': 0.84; 'received:fios.verizon.net': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: pool-173-59-124-74.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: <1590467.kktH0DaBsW@PointedEars.de> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:98381 On 11/6/2015 5:26 PM, Thomas 'PointedEars' Lahn wrote: > Bartc wrote: >> import math >> >> math.pi=3D0 >> >> print (math.pi) >> >> In Python, presumably 'pi' is just another variable, and variables can= >> be written to. > > =E2=80=9Cpi=E2=80=9D is the name of an attribute of the module object r= eferred to by =E2=80=9Cmath=E2=80=9D. > >> (Perhaps math.pi would be better off as a function.) > > Perhaps not. Calling a function includes an overhead that one does not= want > in already costly floating-point calculations. > > In my opinion, mathematical constants should be implemented as constant= s > (non-overwritable, non-deletable, throwing exceptions when attempting t= o do > either) but apparently the authors of math.py disagree. One of multiple discussions of the 'constants' idea. bugs.python.org/issue1465406 It is mostly about speed. --=20 Terry Jan Reedy