Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:

Guido wrote:

> it would require the math.log function to recognize rationals

I don't think it would. You don't need a type-check, you just need to check for 
a pair of numerator and denominator attributes.

So we could do something like this, except in C:

    try:
        return log(float(x))
    except DomainError:
        try:
            a = x.numerator
            b = x.denominator
        except AttributeError:
            pass
        else:
            return log(a) - log(b)
        raise

----------
nosy: +steven.daprano

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42886>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to