[Python-Dev] Symmetry arguments for API expansion (original) (raw)
David Mertz mertz at gnosis.cx
Mon Mar 12 19:14:50 EDT 2018
- Previous message (by thread): [Python-Dev] Symmetry arguments for API expansion
- Next message (by thread): [Python-Dev] Symmetry arguments for API expansion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Mar 12, 2018, 3:25 PM Tim Peters <tim.peters at gmail.com> wrote:
[David Mertz <mertz at gnosis.cx>] > ... > I can see no sane reason why anyone would ever call float.isinteger() > actually. That should always be spelled math.isclose(x, int(x)) because > IEEE-754. Attractive nuisance is probably too generous, I'd simply call the > method a bug.
Sometimes it's necessary to know, and especially when implementing 754-conforming functions. For example, what negative infinity raised to a power needs to return depends on whether the power is an integer (specifically on whether it's an odd integer): >>> (-math.inf) ** 3.1 inf
Weird. I take it that's what IEEE-754 says. NaN would sure be more intuitive here since inf+inf-j is not in the domain of Reals. Well, technically neither is inf, but at least it's the limit of the domain. :-).
(-math.inf) ** 3.0 # NOTE THIS ONE -inf >>> (-math.inf) ** 2.9 inf But, ya, for most people most of the time I agree isinteger() is an attractive nuisance. People implementing math functions are famous for cheerfully enduring any amount of pain needed to get the job done ;-) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180312/b7b7d350/attachment.html>
- Previous message (by thread): [Python-Dev] Symmetry arguments for API expansion
- Next message (by thread): [Python-Dev] Symmetry arguments for API expansion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]