If you and Cade want to co-author a PEP that adds `inf` and `nan` to the builtins, I'll sponsor it, so you can have a fair hearing from the SC. I won't argue in favor, but not against either.)
On Tue, Sep 8, 2020 at 6:26 PM Christopher Barker email@example.com wrote:
Thanks Jon and Chris. But I'm not looking to make a literal_eval or custom reprs that support inf and nan -- I may need that some day, so thanks for the tips, but the idea here is to do that little bit more to make Python better support the float special values out of the box.
It seems that moving math,inf and math.nan to __builtins__, and adding them to a "whitelist" in literal_eval (and maybe another place or two?) would accomplish this. Small benefit, yes, but I have yet to hear anyone present a downside (other than the usual it's work that someone has to do).
I took another look at PEP 754 (which was rejected due to disinterest, not because it was determined to be a bad idea), and note that the only part that wasn't implemented was the creation of "constants" in __builtins__ (and, indeed, the PEP is not clear on whether it was suggesting that they be in __builtins__ at all). The PEP also called for different names, and a constant for negative Infinity, which doesn't seem very useful when you can just use a negative sign.
Anyway, I'm done now -- there hasn't been any interest from core devs, and I don't care enough to push this, but it would be nice.
-- Christopher Barker, PhD
Python Language Consulting
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython
Python-ideas mailing list -- firstname.lastname@example.org To unsubscribe send an email to email@example.com https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://firstname.lastname@example.org/message/4VK6ND... Code of Conduct: http://python.org/psf/codeofconduct/