[Python-ideas] Re: 'Infinity' constant in Python

2020-09-15 Thread Paul Moore
On Tue, 15 Sep 2020 at 06:54, David Mertz wrote: > > Thanks so much Ben for documenting all these examples. I've been frustrated > by the inconsistencies, but hasn't realized all of those you note. > > It would be a breaking change, but I'd really vastly prefer if almost all of > those OverflowE

[Python-ideas] Re: 'Infinity' constant in Python

2020-09-15 Thread Stephen J. Turnbull
Ben Rudiak-Gould writes: > 1./0. is not a true infinity. Granted, I was imprecise. To be precise, 1.0 / 0.0 *could* be a true infinity, and in some cases (1.0 / float(0)) *provably* is, while 1e1000 *provably* is not a true infinity. ___ Python-ideas

[Python-ideas] Re: A shortcut to load a JSON file into a dict : json.loadf

2020-09-15 Thread Stephen J. Turnbull
Joao S. O. Bueno writes: > If .load and .dump are super-charged, people coding with these > methods in mind have _one_ less_ thing to worry about: if the > method accepts a path or an open file becomes irrelevant. But then you either lose the primary benefit of this three line function (defaul

[Python-ideas] Re: 'Infinity' constant in Python

2020-09-15 Thread Steve Barnes
> We need to remember that a significant number of Python users don't > have any idea what IEE-754 is, and have never heard of a NaN (and > possibly even of infinity as a number). Those people are *far* better > served by being told "you made a mistake" in the form of an exception, > rather than

[Python-ideas] Re: 'Infinity' constant in Python

2020-09-15 Thread Stephen J. Turnbull
Chris Angelico writes: > In mathematics, "infinity" isn't a value. One cannot actually perform > arithmetic on it. That's a rather controversial opinion. Even intuitionist mathematicians perform arithmetic on infinities; they just find it very distasteful that they have to do so. > Computers

[Python-ideas] Re: Fwd: Re: Experimenting with dict performance, and an immutable dict

2020-09-15 Thread Inada Naoki
On Tue, Sep 15, 2020 at 5:08 AM Marco Sulla wrote: > > 1. How can we check the size of an object only if it's an iterable > using the Python C API? There is no good way. Additionally, we need to know distinct count if we want to preallocate hash table. For example, `len(dict(["foo"]*1000))` is 1,

[Python-ideas] Re: 'Infinity' constant in Python

2020-09-15 Thread Chris Angelico
On Tue, Sep 15, 2020 at 5:17 PM Stephen J. Turnbull wrote: > > Chris Angelico writes: > > > In mathematics, "infinity" isn't a value. One cannot actually perform > > arithmetic on it. > > That's a rather controversial opinion. Even intuitionist > mathematicians perform arithmetic on infinities;

[Python-ideas] Re: 'Infinity' constant in Python

2020-09-15 Thread Paul Moore
On Tue, 15 Sep 2020 at 08:12, Stephen J. Turnbull wrote: > > Ben Rudiak-Gould writes: > > > 1./0. is not a true infinity. > > Granted, I was imprecise. To be precise, 1.0 / 0.0 *could* be a true > infinity, and in some cases (1.0 / float(0)) *provably* is, while > 1e1000 *provably* is not a true

[Python-ideas] Re: 'Infinity' constant in Python

2020-09-15 Thread Stephen J. Turnbull
Paul Moore writes: > On Tue, 15 Sep 2020 at 08:12, Stephen J. Turnbull > wrote: > > Ben Rudiak-Gould writes: > > > 1./0. is not a true infinity. > > Granted, I was imprecise. To be precise, 1.0 / 0.0 *could* be a true > > infinity, and in some cases (1.0 / float(0)) *provably* is, while

[Python-ideas] Re: 'Infinity' constant in Python

2020-09-15 Thread Stephen J. Turnbull
Chris Angelico writes: > Hang on hang on, transcendental quantities are still finite. It may > take an infinite sequence to fully calculate them, but they are finite > values. We're not talking about pi here, we're talking about treating > "infinity" as a value. You can certainly do arithmetic

[Python-ideas] Re: Fwd: Re: Experimenting with dict performance, and an immutable dict

2020-09-15 Thread Marco Sulla
On Tue, 15 Sep 2020 at 09:22, Inada Naoki wrote: > > On Tue, Sep 15, 2020 at 5:08 AM Marco Sulla > wrote: > > > > 1. How can we check the size of an object only if it's an iterable > > using the Python C API? > > There is no good way. Additionally, we need to know distinct count if > we want to p

[Python-ideas] Re: 'Infinity' constant in Python

2020-09-15 Thread Paul Moore
On Tue, 15 Sep 2020 at 10:29, Stephen J. Turnbull wrote: > > Paul Moore writes: > > On Tue, 15 Sep 2020 at 08:12, Stephen J. Turnbull > > wrote: > > > Ben Rudiak-Gould writes: > > > > > 1./0. is not a true infinity. > > > > Granted, I was imprecise. To be precise, 1.0 / 0.0 *could* be a tr

[Python-ideas] Re: 'Infinity' constant in Python

2020-09-15 Thread Cade Brown
To sum up these discussions, I think it should be said that perhaps a look should be taken at the structure of math-based errors and exceptions, but this discussion should be moved to a new thread on the mailing list perhaps. (I agree that the exceptions make little sense, and I have noticed this)

[Python-ideas] Re: 'Infinity' constant in Python

2020-09-15 Thread Stephen J. Turnbull
Paul Moore writes: > OK, so to me, 1.0 / 0.0 *is* a "true infinity" in that sense. If you > divide "one" by "zero" the only plausible interpretation - if you > allow infinity in your number system - is that you get infinity as > a result. Of course that just pushes the question back to whether

[Python-ideas] Re: A shortcut to load a JSON file into a dict : json.loadf

2020-09-15 Thread Wes Turner
json.load and json.dump already default to UTF8 and already have parameters for json loading and dumping. json.loads and json.dumps exist only because there was no way to distinguish between a string containing JSON and a file path string. (They probably should've been .loadstr and .dumpstr, but i

[Python-ideas] Re: A shortcut to load a JSON file into a dict : json.loadf

2020-09-15 Thread Christopher Barker
On Tue, Sep 15, 2020 at 12:21 AM Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > > If .load and .dump are super-charged, people coding with these > > methods in mind have _one_ less_ thing to worry about: if the > > method accepts a path or an open file becomes irrelevant. >

[Python-ideas] Re: 'Infinity' constant in Python

2020-09-15 Thread Steve Barnes
>>> 1 / 0 >>> 1 / 0.0 inf Is not true as since python 3 has adopted true division 1/1 returns 1.0 so 1/0 would also return inf. Steve Barnes Sent from Mail for Windows 10 From: Cade Brown Sent: 15 September 2020 15

[Python-ideas] Re: 'Infinity' constant in Python

2020-09-15 Thread Paul Moore
On Tue, 15 Sep 2020 at 16:48, Stephen J. Turnbull wrote: > > Paul Moore writes: > > > OK, so to me, 1.0 / 0.0 *is* a "true infinity" in that sense. If you > > divide "one" by "zero" the only plausible interpretation - if you > > allow infinity in your number system - is that you get infinity as

[Python-ideas] Re: A shortcut to load a JSON file into a dict : json.loadf

2020-09-15 Thread Marco Sulla
On Tue, 15 Sep 2020 at 18:10, Wes Turner wrote: > > json.loads and json.dumps exist only because there was no way to distinguish > between a string containing JSON and a file path string. > (They probably should've been .loadstr and .dumpstr, but it's too late for > that now) Well, if you see t

[Python-ideas] Re: A shortcut to load a JSON file into a dict : json.loadf

2020-09-15 Thread Christopher Barker
On Tue, Sep 15, 2020 at 9:09 AM Wes Turner wrote: > json.load and json.dump already default to UTF8 and already have > parameters for json loading and dumping. > yes, of course. json.loads and json.dumps exist only because there was no way to > distinguish between a string containing JSON and a

[Python-ideas] Re: A shortcut to load a JSON file into a dict : json.loadf

2020-09-15 Thread Wes Turner
On Tue, Sep 15, 2020 at 7:30 PM Christopher Barker wrote: > On Tue, Sep 15, 2020 at 9:09 AM Wes Turner wrote: > >> json.load and json.dump already default to UTF8 and already have >> parameters for json loading and dumping. >> > > yes, of course. > > json.loads and json.dumps exist only because

[Python-ideas] Re: Fwd: Re: Experimenting with dict performance, and an immutable dict

2020-09-15 Thread Marco Sulla
Well, I simply forgot vectorcall. I've done a test and it seems the speedup is about 25%. Unluckily, now I abandoned definitively the hope of a big big resize, but it seems I don't resize correctly, since now I have again an assert error on dk_usable. What is the difference between dk_usable and