Thanks for all the input!
I don't know if I agree that it's a slippery slope, since copysign seems to me of a different nature compared to e.g. sin.
How important to use this: Many languages do feature a sign function, if that's of any worth. copysign is python's closest built-in equivalent.
I did realise this is probably a bit of an X/Y problem. I gave the example of range, where int values are required. I was using it like this: range(start, end, sign(end-start)), to automatically have a range going up or down. But that's really the only concrete case I know. So then it might really come down to range not accepting floats, which I think is an old topic.
On Fri, 29 Nov 2019 at 17:58, Christopher Barker email@example.com wrote:
On Fri, Nov 29, 2019 at 8:30 AM Brandt Bucher firstname.lastname@example.org wrote:
Yep. It’s also the only way that I know of to get the sign of a NaN. We can’t even parse the repr for that!
Exactly -- while a tiny bit handy for ints, floats are where it is really *needed*.
And back to Guido's point -- while called "math", the math module really is a "float_math" module. It began as a wrapper around the C math library, and while it has grown a number of Python specific functions, I'm pretty sure all the ones that reflect C math functions are essentially unchanged, and it should probably stay that way.
-- Christopher Barker, PhD
Python Language Consulting
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython
Python-ideas mailing list -- email@example.com To unsubscribe send an email to firstname.lastname@example.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://email@example.com/message/HGRTJR... Code of Conduct: http://python.org/psf/codeofconduct/