[issue20341] Argument Clinic: add "nullable ints"

2020-03-18 Thread Brett Cannon
Change by Brett Cannon : -- nosy: -brett.cannon ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail

[issue20341] Argument Clinic: add "nullable ints"

2018-06-14 Thread Tal Einat
Change by Tal Einat : -- nosy: -taleinat ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python

[issue20341] Argument Clinic: add "nullable ints"

2015-02-25 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- components: +Argument Clinic ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: h

[issue20341] Argument Clinic: add "nullable ints"

2014-10-22 Thread Josh Rosenberg
Changes by Josh Rosenberg : -- nosy: +josh.r ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue20341] Argument Clinic: add "nullable ints"

2014-08-01 Thread Martin v . Löwis
Martin v. Löwis added the comment: If this feature is contentious, then a PEP is need to decide on it. As it turns out, PEP 436 already discusses the nullable feature. But, as it also turns out, PEP 436 hasn't been accepted yet (at least I could not find any records on that having happened, an

[issue20341] Argument Clinic: add "nullable ints"

2014-07-31 Thread Raymond Hettinger
Raymond Hettinger added the comment: Larry, ISTM that you are bulldozing your way through something that isn't an actual problem to be solved. > I can see why you'd think this was a waste of time. I don't think it is just a waste of time; I think it is a bad idea. You have a very strong no

[issue20341] Argument Clinic: add "nullable ints"

2014-07-31 Thread Larry Hastings
Larry Hastings added the comment: FWIW, Martin agreed with me at EuroPython that "nullable int" is the proper name. So does Wikipedia: http://en.wikipedia.org/wiki/Nullable_type As for "repeat_new": like I said, I don't intend to check in this change when checking in nullable ints. (I

[issue20341] Argument Clinic: add "nullable ints"

2014-07-31 Thread Raymond Hettinger
Raymond Hettinger added the comment: FWIW, I agree with Antoine that Nullable Int is a misnomer. Also, I don't buy into this mission to change signatures for optional ints into int-or-none. In particular, itertools.repeat() is fine as-is. Optional int APIs have been around for a long time,

[issue20341] Argument Clinic: add "nullable ints"

2014-07-30 Thread Larry Hastings
Larry Hastings added the comment: Whoops, here's the patch. -- Added file: http://bugs.python.org/file36165/larry.nullable.ints.4.txt ___ Python tracker ___ _

[issue20341] Argument Clinic: add "nullable ints"

2014-07-30 Thread Larry Hastings
Larry Hastings added the comment: Here's a fresh patch. After discussing with Martin at EuroPython, I moved the implementation into Python/getargs.c, and the prototypes into modsupport.h. I'm still using the example of "repeat.new" to show what it looks like and how it works. However I don'

[issue20341] Argument Clinic: add "nullable ints"

2014-01-23 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- nosy: -pitrou ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue20341] Argument Clinic: add "nullable ints"

2014-01-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: > I would color your final sentence slightly. Yes, there are plenty of > legitimate discussions about API semantics and nomenclature. But > there are infinitely many pointless and time-wasting discussions. > Therefore not every question about API and naming dec

[issue20341] Argument Clinic: add "nullable ints"

2014-01-23 Thread Larry Hastings
Larry Hastings added the comment: I don't think it's fair to call my responses "snarky". On the other hand, your suggestion that I view Argument Clinic as "my toy project" is obviously meant as an insult. It is fair to call my responses "dismissive", because I find nothing compelling about y

[issue20341] Argument Clinic: add "nullable ints"

2014-01-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Drop. It. Seriously? Why exactly did you ask for comments if your only response is to be snarky and dismissive? This is not your toy project. It is perfectly legitimate for us to question API and naming decisions. -- ___

[issue20341] Argument Clinic: add "nullable ints"

2014-01-23 Thread Larry Hastings
Larry Hastings added the comment: Drop. It. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.py

[issue20341] Argument Clinic: add "nullable ints"

2014-01-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: > How many existing occurrences of "or_none" did you find in the CPython > tree? If I split that into the individual words "or" and "None", quite a lot. Looking for "or None" turns quite a bunch of matches too. "or_none" simply applies the PEP 8 convention for

[issue20341] Argument Clinic: add "nullable ints"

2014-01-23 Thread Larry Hastings
Larry Hastings added the comment: How many existing occurrences of "or_none" did you find in the CPython tree? Perhaps we can turn our attention to other languages like SQL and C# and borrow their term for "value that is allowed to be of a specific type (or types) as well as the null value".

[issue20341] Argument Clinic: add "nullable ints"

2014-01-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: The only place where "nullable" appears in the doc tree is... clinic.rst (in reference to places where a C pointer can be NULL, which *is* a reasonable use of the term). There's another problem in the patch: if you define "nullable_int_t" and "nullable_Py_ssi

[issue20341] Argument Clinic: add "nullable ints"

2014-01-23 Thread Larry Hastings
Larry Hastings added the comment: I think it's a fine name, otherwise I would not have chosen it in the first place. Your high-spirited bikeshedding has been noted and not acted upon. I have no plans to change the name. Please drop it. -- ___ Pyt

[issue20341] Argument Clinic: add "nullable ints"

2014-01-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: I insist that "nullable" is a very bad name. It also suggests that somehow we'll get a NULL pointer (in C) when the parameter is absent or None, which is not the case. -- ___ Python tracker

[issue20341] Argument Clinic: add "nullable ints"

2014-01-23 Thread Larry Hastings
Larry Hastings added the comment: > > Yes, that is a different name that seems to mean much the same > > thing. > and which is much more understandable by a Python developer. Thanks for your opinion. > > Changing error to an char and moving it to the end would > > save exactly zero bytes, beca

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Larry Hastings
Larry Hastings added the comment: Fix attached. Might as well. -- Added file: http://bugs.python.org/file33639/larry.nullable.ints.draft.3 ___ Python tracker ___ ___

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Tal Einat
Tal Einat added the comment: The new patch still uses NULLABLE_PY_SSIZE_T_INITIALIZE instead of NULLABLE_INT_T_INITIALIZE in one place in int_converter.converter_init. -- ___ Python tracker ___

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Antoine Pitrou
Antoine Pitrou added the comment: > > int(or_none=True) ? > > Yes, that is a different name that seems to mean much the same thing. and which is much more understandable by a Python developer. > Changing error to an char and moving it to the end would > save exactly zero bytes, because the com

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Larry Hastings
Larry Hastings added the comment: > int(or_none=True) ? Yes, that is a different name that seems to mean much the same thing. > Hmm, do we have a getargs.h ? No. Would it help if I attached the output of "ls Include" to this issue? > > > - boolean fields can be "char" instead of "int" (and

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Tal Einat
Tal Einat added the comment: Another bug in the patch: In int_converter.__init__ in clinic.py, the patch adds: if not isinstance(self.default, int): fail("Illegal default value for int_converter") This fails if no default is specified, e.g. for positional only argument. The condition shou

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Antoine Pitrou
Antoine Pitrou added the comment: > That's not what it means. Python parameters are "optional" if they > have a default value. These parameters are "nullable", in the sense > that they can be either of a specific type or "None". (But "Noneable" > seemed like a bad name). They are not necessari

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Larry Hastings
Larry Hastings added the comment: - the concept of a nullable thing in Python doesn't exist; why not "optional"? That's not what it means. Python parameters are "optional" if they have a default value. These parameters are "nullable", in the sense that they can be either of a specific type or "

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Antoine Pitrou
Antoine Pitrou added the comment: Some things: - the concept of a nullable thing in Python doesn't exist; why not "optional"? - why is there a "error" field in the new structs? - the fact that the structs are defined in longobject.h looks bonkers - boolean fields can be "char" instead of "int" (a

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Tal Einat
Tal Einat added the comment: Found two bugs in the draft patch in Objects/longobject.c: 1) In _PyLong_NullableIntConverter, there is no index variable, so the Py_DECREF and Py_XDECREF need to be removed from the end of the function. 2) In _PyLong_NullablePy_ssize_tConverter, the index variable

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Jeremy Kloth
Changes by Jeremy Kloth : -- nosy: +jkloth ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Larry Hastings
Larry Hastings added the comment: Actually, the documented behavior of itertools.repeat() is that the "times" argument takes a default of None. Equivalent to: def repeat(object, times=None): ... http://docs.python.org/3/library/itertools.html#itertools.repeat --

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Larry Hastings
Larry Hastings added the comment: I guess we should ask Guido for clarification. But I got the impression that we could *gently* tweak the signatures of functions if they were not representable in Python syntax. He thought that giving the parameter of _sha1.sha1() a default value of b'' was

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I thought it was too late for 3.4, and the conversion should not change the behavior (we can change the behavior later in 3.5). -- ___ Python tracker ___

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Larry Hastings
Larry Hastings added the comment: Then you disagree with Guido, who says that optional integer arguments without a viable publishable default value should accept None to mean "use the default value": https://mail.python.org/pipermail/python-dev/2014-January/131673.html https://mail.python.org/

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: And thank you for the fix for the __init__ methods. Could you please commit it? The I'll update patches for bz2 and lzma modules. Looks as Vajrasky Kok has encountered with yet one bug in generated __init__ wrapper(issue20185). -- _

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > I don't remember who specifically needed the nullable ints, so I just added a > bunch of Derby contestants. There are no much need in nullable ints, if they are needed, different use cases require different semantic. I don't think we can now write general

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Tal Einat
Tal Einat added the comment: My only comment from reviewing the patch is that you seem to have used NULLABLE_PY_SSIZE_T_INITIALIZE by accident one time in int_converter (in clinic.py). Other than that, as you already know, make sure to return 1 in both converters in the "if (arg == Py_None)"

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Tal Einat
Tal Einat added the comment: You look very handsome today Larry :) Regardless, I do think this is a good idea. I've converted several functions that have -1 as a default value for ints where they ideally should have None. Having None as the default will be much clearer and less error prone for

[issue20341] Argument Clinic: add "nullable ints"

2014-01-22 Thread Larry Hastings
Larry Hastings added the comment: The bug you saw was an easy fix; the converter function needs to return 1 (success) from the "== Py_None" branch. And yes, more unit tests would be good, fixing the documentation would be good too. I did say the patch was nowhere near ready. I will assume un

[issue20341] Argument Clinic: add "nullable ints"

2014-01-21 Thread Vajrasky Kok
Vajrasky Kok added the comment: >>> itertools.repeat.__doc__ 'repeat(object, times=None)\nReturns an iterator which returns the object the specified number of times.\n\nIf times is None, returns the object endlessly.' >>> itertools.repeat('a', times=None) Traceback (most recent call last): Fil

[issue20341] Argument Clinic: add "nullable ints"

2014-01-21 Thread Larry Hastings
Larry Hastings added the comment: I should have mentioned--a sample using nullable ints is in itertoolsmodule.c. longobject.{ch} changed to add the converters, and obviously clinic.py changed to add support for the converters. -- ___ Python tracker

[issue20341] Argument Clinic: add "nullable ints"

2014-01-21 Thread Larry Hastings
New submission from Larry Hastings: Attached is a *preliminary* patch for Argument Clinic that adds nullable ints. If you use the converter "int(nullable=True), then: * The type you get back is not int but "nullable_int_t", a structure containing three fields: "error", "is_null", and "i". "