[Python-Dev] Symmetry arguments for API expansion
Antoine Pitrou
solipsis at pitrou.net
Mon Mar 12 14:10:27 EDT 2018
On Mon, 12 Mar 2018 09:49:27 -0700
Raymond Hettinger <raymond.hettinger at gmail.com> wrote:
>
> Starting point: Do we need this?
> * We already have a simple, traditional, portable, and readable way to make the test: int(x) == x
It doesn't look that obvious to me. As a reviewer I would request to
add a comment explaining the test.
> * Aside from the OP, this behavior has never been requested in Python's 27 year history.
That's possible. One thing I often see is suboptimal compatibility
with third-party integer types such as Numpy ints, but that's a
slightly different request (as it usually doesn't imply accepting
Numpy floats that exactly represent integrals).
> Does it cost us anything?
> * Yes, adding a method to the numeric tower makes it a requirement for every class that ever has or ever will register or inherit from the tower ABCs.
Well, the big question is whether the notion of numeric tower is useful
in Python at all. If it's useful then there's a point to expand its
usability with such a feature. Personally I don't care much :-)
> As a result, we ended-up with an awkward and error-prone API that requires double parenthesis for the valid use case: url.endswith(('.html', '.css')).
It doesn't look that awkward to me.
Regards
Antoine.
More information about the Python-Dev
mailing list