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

2020-09-14 Thread David Mertz
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 OverflowErrors and others were simply infinities. That's much closer to

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

2020-09-14 Thread Joao S. O. Bueno
On Fri, 11 Sep 2020 at 19:50, David Mertz wrote: > I like the idea of having these functions, but I don't like overloading > the argument to a function with "filename or file-like object" as is common > in libraries like Pandas. I think there are a few places the standard > library does it, but

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

2020-09-14 Thread Ben Rudiak-Gould
On Mon, Sep 14, 2020 at 9:36 AM Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > Christopher Barker writes: > > IEEE 754 is a very practical standard -- it was well designed, and is > > widely used and successful. It is not perfect, and in certain use > cases, it > > may not

[Python-ideas] Re: Custom keywords (from: Decorators for class non function properties)

2020-09-14 Thread Marco Sulla
Little errata: change Cython, for example, uses its parser to compile Python code to Cython, for example, uses its parser to compile Cython code ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...

[Python-ideas] Re: Custom keywords (from: Decorators for class non function properties)

2020-09-14 Thread Marco Sulla
On Sun, 23 Aug 2020 at 02:42, Guido van Rossum wrote: > IMO this is just too large of a step to expect either redradrist or Marco > Sulla to take. You're quite right, I have proposed it to have an opinion by experts. Indeed I have no knowledge about how a parser works. This is why I asked if thi

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

2020-09-14 Thread Serhiy Storchaka
14.09.20 19:55, Chris Angelico пише: > I think not; unless there are API details to be hashed out or > counterarguments to be rebuffed, I think this is fairly simple and > non-controversial. I also considered this issue simple and non-controversial. But the discussion turned in an unexpected direc

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-09-14 Thread Marco Sulla
I just had an idea: we have mp->ma_used and keys->dk_nentries. holes = mp->ma_keys->dk_nentries - mp->ma_used is the number of holes in the dict. So, if holes == 0, you have O(1). But, if the dict has holes, you can't have O(1), but you can speedup the check of the entry by counting the NULLs in

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

2020-09-14 Thread Marco Sulla
Well, I didn't read the entire discussion... but I wrote in unsuspicious times a stupid little module, msutils, with two stupid little functions, jsonLoad and jsonDump: https://github.com/Marco-Sulla/msutils/blob/master/msutils/jsonutil.py#L20 ___ Python

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

2020-09-14 Thread Marco Sulla
@Inada (senpai?): In the meanwhile I tried to apply some tricks to speedup the dict creation without success. This is my effort: https://github.com/Marco-Sulla/cpython/blob/master/Objects/dictobject.c As you can see, I simply "cloned" some functions that create dict, and removed some checks that

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

2020-09-14 Thread Guido van Rossum
On Mon, Sep 14, 2020 at 9:58 AM Chris Angelico wrote: > On Tue, Sep 15, 2020 at 2:41 AM Christopher Barker > wrote: > > > > There seems to be a fair bit of support for this idea. > > > > Will it need a PEP ? > > I think not; unless there are API details to be hashed out or > counterarguments to

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

2020-09-14 Thread Christopher Barker
On Mon, Sep 14, 2020 at 10:00 AM Chris Angelico wrote: > On Tue, Sep 15, 2020 at 2:41 AM Christopher Barker > wrote: > > > > There seems to be a fair bit of support for this idea. > > > > Will it need a PEP ? > > I think not; unless there are API details to be hashed out or > counterarguments

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

2020-09-14 Thread Chris Angelico
On Tue, Sep 15, 2020 at 3:45 AM Richard Damon wrote: > > On 9/14/20 12:34 PM, Stephen J. Turnbull wrote: > > That's fine, but Python doesn't give you that. In floats, 0.0 is not > > true 0, it's the set of all underflow results plus true 0. So by your > > argument, in float arithmetic, we should

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

2020-09-14 Thread Richard Damon
On 9/14/20 12:34 PM, Stephen J. Turnbull wrote: > That's fine, but Python doesn't give you that. In floats, 0.0 is not > true 0, it's the set of all underflow results plus true 0. So by your > argument, in float arithmetic, we should not have ZeroDivisionErrors. > But we do raise them. Actually,

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

2020-09-14 Thread Chris Angelico
On Tue, Sep 15, 2020 at 2:41 AM Christopher Barker wrote: > > There seems to be a fair bit of support for this idea. > > Will it need a PEP ? > I think not; unless there are API details to be hashed out or counterarguments to be rebuffed, I think this is fairly simple and non-controversial. (If

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

2020-09-14 Thread Christopher Barker
There seems to be a fair bit of support for this idea. Will it need a PEP ? -CHB On Mon, Sep 14, 2020 at 9:20 AM Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > Christopher Barker writes: > > > On Sun, Sep 13, 2020 at 7:58 AM Stephen J. Turnbull < > > > turnbull.stephen...

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

2020-09-14 Thread Stephen J. Turnbull
Christopher Barker writes: > On Sun, Sep 13, 2020 at 8:10 AM Stephen J. Turnbull < > turnbull.stephen...@u.tsukuba.ac.jp> wrote: > > > As Steven points out, it's an overflow, and IEEE *but not Python* is > > clear about that. In fact, none of the actual infinities I've tried > > (1.0 / 0.0

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

2020-09-14 Thread Stephen J. Turnbull
Christopher Barker writes: > On Sun, Sep 13, 2020 at 7:58 AM Stephen J. Turnbull < > turnbull.stephen...@u.tsukuba.ac.jp> wrote: > > > > encoding=None: this is the important one -- json is always UTF-8 yes? > > > > Standard JSON is always UTF-8. Nevertheless, I'm quite sure that > > there

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

2020-09-14 Thread Cade Brown
To me it seems like a useful shortcut that means: >>> x == True and type(x) == bool But, as you say, it is best to just let the Python interpreter treat it as a boolean (i.e. within an `if`, it is converted automatically) Now, I am thinking it would actually be *bad* to have the CPython impleme