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


Groups > comp.lang.python > #52719

Re: Importing variables non-deterministic?

Date 2013-08-20 08:55 +0200
From Antoon Pardon <antoon.pardon@rece.vub.ac.be>
Subject Re: Importing variables non-deterministic?
References (4 earlier) <5211D464.5090303@rece.vub.ac.be> <mailman.17.1376901181.19984.python-list@python.org> <52125071$0$29986$c3e8da3$5496439d@news.astraweb.com> <mailman.40.1376944517.19984.python-list@python.org> <52130335$0$29885$c3e8da3$5496439d@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.49.1376981719.19984.python-list@python.org> (permalink)

Show all headers | View raw


Op 20-08-13 07:48, Steven D'Aprano schreef:
> On Mon, 19 Aug 2013 22:34:00 +0200, Antoon Pardon wrote:
> 
>> Op 19-08-13 19:05, Steven D'Aprano schreef:
>>
>>
>>> I wish Python had stronger support for enforcing constantness, to whit,
>>> some way to say "you can't rebind or delete this name once it is
>>> bound". You can do it with attributes, by use of property, or in C
>>> extensions, but you cannot do it with top-level name bindings. It makes
>>> me terribly sad that you can do this:
>>>
>>> import math
>>> math.pi = 3.0
>>>
>>>
>>> although I can't decide whether I am less sad or more sad to see that
>>> the behaviour of math.sin and friends doesn't depend on math.pi.
>>
>> Why should you expect math.sin and friends be dependant on math.pi?
>> AfAIR the numerical algorithms for calulating sin and friends don't
>> depend on (the value of) pi. So there is no reason to suspect that
>> altering math.pi would have any effect on the results of these
>> functions.
> 
> 
> Of course they depend on pi. Or rather, they depend on the geometric 
> properties of circles, which are related to pi. If the ratio of the 
> circumference of a circle to its diameter was exactly 3, instead of 
> 3.1415..., then sine and cosine functions would be periodic with period 6 
> rather than τ = 2π.

Which is beside the point. The fact that nπ are the zeropoints of the
sin function doesn't imply in any way that you somehow need to work with
the value of π in order to calculate any result of the function.

Just as the function x^2 - 2 has -√2 and √2 as zeropoints, yet when
given a numerical value, you dont need (the value of) √2 in order to
get the result. So setting a variable like sqrt2 to whatever value
shouldn't lead us to suspect it would influence the zeropoints of
that function. Likewise with π and the calculation of sin.


> If you consider the implementation of sin and cos functions, they usually 
> reduce the argument modulo π to something in the first quadrant, and then 
> use symmetry to adjust the value. So changing the value of pi could, in 
> principle, change the implementation of sin, cos and tan.

Yes there is this aspect, which is a fair point.

-- 
Antoon Pardon

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


Thread

Importing variables non-deterministic? tmellman@googlemail.com - 2013-08-17 07:25 -0700
  Re: Importing variables non-deterministic? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-17 15:01 +0000
    Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-19 09:14 +0200
    Re: Importing variables non-deterministic? Dave Angel <davea@davea.name> - 2013-08-19 07:45 +0000
    Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-19 10:16 +0200
      Re: Importing variables non-deterministic? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-19 16:57 +0000
        Re: Importing variables non-deterministic? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-19 17:16 +0000
          Re: Importing variables non-deterministic? Chris Angelico <rosuav@gmail.com> - 2013-08-19 18:25 +0100
        Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-19 19:40 +0200
    Re: Importing variables non-deterministic? Chris Angelico <rosuav@gmail.com> - 2013-08-19 09:32 +0100
      Re: Importing variables non-deterministic? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-19 17:05 +0000
        Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-19 22:34 +0200
          Re: Importing variables non-deterministic? Steven D'Aprano <steve@pearwood.info> - 2013-08-20 05:48 +0000
            Re: Importing variables non-deterministic? wxjmfauth@gmail.com - 2013-08-19 23:40 -0700
            Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-20 08:55 +0200
              Re: Importing variables non-deterministic? wxjmfauth@gmail.com - 2013-08-20 00:31 -0700
                Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-20 09:55 +0200
                Re: Importing variables non-deterministic? wxjmfauth@gmail.com - 2013-08-20 02:15 -0700
    Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-19 11:03 +0200
    Re: Importing variables non-deterministic? Chris Angelico <rosuav@gmail.com> - 2013-08-19 10:18 +0100
    Re: Importing variables non-deterministic? Peter Otten <__peter__@web.de> - 2013-08-19 11:49 +0200
    Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-19 13:54 +0200
    Re: Importing variables non-deterministic? Dave Angel <davea@davea.name> - 2013-08-19 12:33 +0000
    Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-19 16:55 +0200
    Re: Importing variables non-deterministic? Chris Angelico <rosuav@gmail.com> - 2013-08-19 16:04 +0100
    Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-19 19:25 +0200
    Re: Importing variables non-deterministic? Ben Finney <ben+python@benfinney.id.au> - 2013-08-20 11:14 +1000

csiph-web