[Python-Dev] Mini-Pep: Simplifying the Integral ABC (original) (raw)

Terry Reedy tjreedy at udel.edu
Thu Jun 5 02:59:47 CEST 2008


"Raymond Hettinger" <python at rcn.com> wrote in message news:2745D7EB7C064B16A88E433588021756 at RaymondLaptop1... | From: "Guido van Rossum" <guido at python.org> | > Unless more folks actually say they agree I don't want to go forward | > with this. There was quite a bit of discussion about PEP 3141 and it | > was accepted; striking this much from it with virtually no discussion | > seems wrong to me. || Not sure how to generate more discussion. It seems self-evident | that an abc with lots of abstract methods is inherently less usable | and that bitwise operations go beyond the basic notion of "integeriness".

On reading PEP3141 some months ago and again today, I thought and still do that all the methods that depend on a 2s-complement representation and implementation really belong to an implentation-defined subclass of Integral. But I am not sure of the purpose of the class and of including such concrete methods in an ABC, and so said nothing ;-).

I notice that the similarly implementation-based frexp and ldexp math methods are not in the Real class.

| Requiring all those methods to be defined makes it harder to write | a compliant class. Other than int/long, no currently existing type | matches-up with Integral. Does anyone care about this?

I might some day, for didactic purposes, write integer classes based on prime-factorization or fibonacci representations. I certainly would skip all the 2s-complement methods. But I do not know that I would care much about being 'non-compliant'.

| If something like numpy's int8 eventually grows the required methods, | it is worriesome that the numerator/denominator properties will be | automatically supplied for fractions.py to accept as inputs eventhough | int8's wrap-around behavior makes them entirely unsuitable.

In my view, the members of residue/remainder classes are not really integers unless their usage is carefully restricted to avoid invocation of the mod operation.

Terry Jan Reedy



More information about the Python-Dev mailing list