This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jyasskin
Recipients facundobatista, gvanrossum, jyasskin, mark.dickinson, rhettinger
Date 2008-02-09.20:59:56
SpamBayes Score 0.12079555
Marked as misclassified No
Message-id <1202590797.91.0.632605848191.issue1682@psf.upfronthosting.co.za>
In-reply-to
Content
Mark: Coming from C++, I don't have any intuition on static vs. class
methods. It might be strange to write MyRationalSubclass.from_float()
and get a Rational back, but it might also be strange to write a
subclass with a different constructor and get an error. So go ahead.

Guido: It would be a shame to decide that classes shouldn't inherit from
ABCs for performance reasons. Issue 1762 tracks the problem, but I
haven't paid much attention to it. Let's see if we can fix that before
using virtual inheritance for Rational. Special-casing ints in the
constructor sounds like a good idea, and we can cache the results of
.numerator and .denominator in _add, etc, without having to change the
overall logic, which should save 2μs (leaving 1 on the table).

It could be useful to declare a private constructor that expects ints
that are already in lowest terms, sort of like
decimal._dec_from_triple(). __add__ couldn't use it directly, but
__abs__ could.

I don't think it's too late to rename one of the classes. I'm using
"RationalAbc" inside of rational.py to refer to numbers.Rational, which
is one reason I was positive on adding a suffix to the ABCs, but
renaming this class is fine with me too.
History
Date User Action Args
2008-02-09 20:59:58jyasskinsetspambayes_score: 0.120796 -> 0.12079555
recipients: + jyasskin, gvanrossum, rhettinger, facundobatista, mark.dickinson
2008-02-09 20:59:57jyasskinsetspambayes_score: 0.120796 -> 0.120796
messageid: <1202590797.91.0.632605848191.issue1682@psf.upfronthosting.co.za>
2008-02-09 20:59:57jyasskinlinkissue1682 messages
2008-02-09 20:59:56jyasskincreate