[Python-Dev] basenumber redux

Alex Martelli aleaxit at gmail.com
Mon Jan 16 06:59:20 CET 2006


For the last 2+ years I've been occasionally arguing for the 
introduction of a basenumber (and ideally a baseinteger, but that, to 
me, is a slightly lesser issue) analogous to basestring. Google 
search fo [basenumber site:python.org] for several messages on the 
subject, by me and others; it will also find the recent thread about 
more general abstract baseclasses, which seems to have bogged down on 
such issues as whether sets are mappings.
Now, today, I have _again_ been bit by the lack of basenumber (by a 
bug of mine, fixed by adding decimal.Decimal to a long tuple of 
classes to be passed to an isinstance call -- I hadn't run that 
particular numeric code of mine since the time of Python 2.3, 
apparently), so I'm back to pining for it. The previous discussion 
was short but pretty exhaustive, so I'd ask further discussants to 
refer back to it, rather than repeating it; no blocking issue appears 
to have emerged at that time, plenty of use cases were pointed out, 
etc. Can we PLEASE have basenumber (and maybe baseinteger, so 
sequences can typecheck against that for their indices -- that's the 
key usecase of baseinteger) rather than have them "hijacked" by wider 
consideration of basesequence, basemapping, and so on...? Pretty 
please....? Let's be pragmatic: basenumber isn't at all complicated 
nor controversial, baseinteger hardly at all, so let's accept them 
while pondering on other potential base* classes for as long as it 
takes for the dust to settle....
I'll be happy to draft a PEP if needed (and just as happy to 
eventually provide an implementation patch if the PEP's accepted), 
but wanted to doublecheck on the general issue first!
Alex


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /