You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's not clear what's the best way to deal with numbers.Integral, numbers.Real, etc. Various issues are discussed in python/typeshed#464.
Some relevant questions:
Should int be a subclass of Integral (and similarly for float / Real)? If yes, how should we annotate the stubs? (Let's focus on __add__ and __radd__ -- other operators are probably similar.)
Should stubs prefer Integral and Real to int and float whenever feasible? Many stdlib functions only accept concrete int or float instances, so using them everywhere wouldn't be safe.
Should we recommend user code to use int or Integral by default? If we don't have a consistent convention, integrating codebases that use different conventions could become painful, as Integral should almost certainly not be a subtype of int.
Can we find examples of some typical use cases where just using int / float is not sufficient and Integral / Real could help? How common and important are these use cases?
If (1) is blocked by limitations of the type system, should we look at extending to the type system to better support abstract numeric types? What are the current limitations?
If (1) or (2) requires compromising some type safety, are the gains important enough to make this a worthwhile tradeoff?
The text was updated successfully, but these errors were encountered:
As this issue has been open for more than five years, asks questions, but has no discussion, I am going to close this. The numbers hierarchy is still an open question, but I think we are better served at this point with concrete suggestions than to keep this open.
It's not clear what's the best way to deal with
numbers.Integral
,numbers.Real
, etc. Various issues are discussed in python/typeshed#464.Some relevant questions:
int
be a subclass ofIntegral
(and similarly forfloat
/Real
)? If yes, how should we annotate the stubs? (Let's focus on__add__
and__radd__
-- other operators are probably similar.)Integral
andReal
toint
andfloat
whenever feasible? Many stdlib functions only accept concreteint
orfloat
instances, so using them everywhere wouldn't be safe.int
orIntegral
by default? If we don't have a consistent convention, integrating codebases that use different conventions could become painful, asIntegral
should almost certainly not be a subtype ofint
.int
/float
is not sufficient andIntegral
/Real
could help? How common and important are these use cases?The text was updated successfully, but these errors were encountered: