>> Right, but we already have some special cases:
>
> In [8]: Fraction(2, 3) ** Fraction(3, 1)
> Out[8]: Fraction(8, 27)
>
> Fraction.__pow__ already tries to return Fraction objects where possible.
>


I think the main point to see here is what the scope of a built-in function
should be.
For a fraction module in the stdlib, I would expect that it handle
"symbolically" any fraction multiplication or division of fractions, and
integer power of fractions.
Those are simple and useful cases, that can arise a bit anywhere. Power of
non-integer is a way more complex issue (notably because power of a
non-integer is not a function), and returning the same output as float is
at least an honest way of dealing with those cases.

I'm not really sure a stdlib should even try do deal with that. If I want
to have a symbolic way of handling complex power of fractions, I should
import a specific math library whose specific job is to get this right (the
same way if you want to do matrix stuff you have to import numpy).


--

*Nicolas Rolin*
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to