Taking a quick look at the relevant PEP https://www.python.org/dev/peps/pep-3141/ or the documentation https://docs.python.org/3/library/numbers.html#module-numbers (the PEP has considerably more detail), I get the impression that our Integer and Rational type could be incorporated in the hierarchy without problem, and possibly some benefit. We should just check it doesn't cause some inadvertent speed regression, and we should check that we're actually fully adhering to the contract API. Our real and complex numbers may well fit too. I'm not so sure p-adic would fit. I think incorporating them would make the tower hierarchy into a tree. Same for number field elements (they would be exact, but you can't tell from the types whether they're real or complex).
It looks like Integer, Rational, RealNumber, ComplexNumber already are"Number"s. >From what I understand, an interesting feature of type annotations would be efficiency improvements. I have trouble seeing how something as general as "Number"s would lead to that. So before people start putting effort in extending the Number hierarchy with sage types, it's probably good to have some examples where it produces a tangible benefit. On Thursday, 15 July 2021 at 03:38:59 UTC-7 [email protected] wrote: > Hi, I was looking into typing a bit and realized that our number field > elements are not registered as numbers. So the following will not evaluate > to true: > > sage: import numbers > sage: K.<a> = QuadraticField(2) > sage: isinstance(a, numbers.Number) > > Is there a reason, we do not register number fields in > `rings/numbers_abc.py`? Can I just change this? > > E.g. I want to specify an iterable over numbers via > `Iterable[numbers.Number]`, which would not include our number field > elements currently. > > Jonathan > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/601b8fb0-3b08-47ad-8aa5-b03c8f202e29n%40googlegroups.com.
