Now that Python is beginning to embrace type annotations, is it worth 
revisiting the idea of having extended integers and an integer infinity?

I found myself trying to annotate this line:

events_to_do: Union[int, float] = math.inf

where I am only including float in the union to accommodate math.inf.  

I'm interested in exploring this concrete proposal:

Add a class to the numeric hierarchy 
(https://www.python.org/dev/peps/pep-3141/) ExtendedIntegral whereby  Real 
:> ExtendedIntegral :> Integral.
Add a sentinel math.int_inf that obeys all of the same kinds of rules as 
math.inf does.

Then, I could annotate more simply:

events_to_do: ExtendedIntegral = math.int_inf

With respect to Python, this is discussed somewhat 
here 
https://stackoverflow.com/questions/24587994/infinite-integer-in-python/35725065#35725065.

The name "extended integer" is discussed somewhat 
here https://math.stackexchange.com/questions/1442961/extended-integers.  A 
quick search of papers shows that it is sometimes used in this 
sense: https://scholar.google.com/scholar?q=%22extended+integer

Best,

Neil
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/QFLWTFJMU2RSGBMYP2XMSYA36VYFRDDQ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to