
It will break an ENORMOUS amount of code. Numpy has its own top-level "inf" variable. So all code that uses "from numpy import *" will break.
The fact that so many modules and packages must define an 'inf' is, to me, a signal that such a constant WOULD be useful. All of them (should) be referring to the same value, anyways, so why not make a global constant instead?
You can't argue that 'no one needs an infinity constant' and yet also giving evidence of code breakage of everyone having to define their own infinity constant. Surely you must see that these reasons are why I suggested the constant in the first place.
Now, obviously, numpy should probably define their own infinity just for completeness, because it is supposed to be a comprehensive package.
Perhaps the infinity constant should be a builtin which can be shadowed instead of a keyword (that way, no pre-existing code would break, except really weird code that only works if 'inf' is *not* defined).
---- *Cade Brown* Research Assistant @ ICL (Innovative Computing Laboratory) Personal Email: brown.cade@gmail.com ICL/College Email: cade@utk.edu
On Sat, Sep 5, 2020 at 1:00 PM Steven D'Aprano steve@pearwood.info wrote:
On Fri, Sep 04, 2020 at 06:30:39PM -0400, Todd wrote:
It will break an ENORMOUS amount of code. Numpy has its own top-level "inf" variable. So all code that uses "from numpy import *" will break.
Yeah no.
py> import builtins py> builtins.inf = "Hello world!" py> inf 'Hello world!' py> from numpy import * py> inf inf
Making inf a keyword would certainly break code, but adding it to builtins would not.
By the way, the numpy inf is a float, so literally the same value and type as the proposed inf/Infinity builtin. The only way you could tell them apart is by identity tests.
-- Steve _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/73Z5N3... Code of Conduct: http://python.org/psf/codeofconduct/