[Python-ideas] float('∞')=float('inf')

Steven D'Aprano steve at pearwood.info
Sat Jul 13 12:45:53 CEST 2013


On 12/07/13 23:09, Gerald Britton wrote:

> Do you have the infinity symbol on your keyboard?  I don't!

Oh, you probably do.

On Windows: Hold down ALT and type 236 on the numeric keypad.

On Mac: Option-5

On Linux: Don't ask. It is possible, but only three men have ever understood how. One of them is now dead. The second is a German professor who has gone mad. And the third was me, but I have forgotten. (Apologies to Lord Palmertson.)


Lack of keyboard support for non-ASCII characters is only a weak argument against. Firstly, nobody will be forced to type such non-ASCII characters. Alternatives include copy and paste, Character Map applications, or simply not using them at all. Secondly, if there is need for entering such characters, I am sure that people will develop ways to do so. After all, people manage to enter Japanese and Chinese, and program in APL.

I do not believe that ∞ is an important enough value for most developers that Python should support it natively. If Python were *my* language, I would quite likely include ∞ as a built-in literal for infinity (but which one? float or Decimal?) but I recognise that is my personal quirk, a little like spelling "not equal" as != instead of <> as the FLUFL intended.

[Aside: there's precedent for a programming language to understand ∞ directly. It has been many years since I last used it, but my recollection of Apple's HyperTalk was that ∞ was recognised as infinity. I may be confabulating this though.]

If Python were more heavily oriented towards mathematics, then it would be arguable that ∞ should be a literal, or at least the '∞' be understood by float. But it's not, so although I personally would use float('∞') or even a literal ∞, I don't think it is useful enough to the average Python programmer to justify the added complexity to the language. As tiny as that added complexity is, the added benefit is even tinier.

So although my personal preference is to say "F--- yeah!" to the idea, being responsible to the entire community, my vote goes to -1. Those who want to support ∞ can write code to support it.

The same goes to suggestions that Python support Unicode numeric non-digits like Roman numerals, fractional forms, circled numbers, etc. If you need that, write a function. The benefit to the language is smaller than the increased complexity, so -1.




-- 
Steven


More information about the Python-ideas mailing list