On Thu, 30 Aug 2018 at 14:06, Nicolas Rolin <nicolas.ro...@tiime.fr> wrote:
> I think you could take the implementation further and decide that any > power of Fraction(1) is Fraction(1) and any positive power of Fraction(0) > is Fraction(0). > I woudn't be shocked that Fraction(1) ** 3.7 == Fraction(1) and > Fraction(0) ** 3.7 == 0. > You could do lots of things. But are any of them useful enough to warrant changing documented behaviour, breaking backward compatibility, and introducing a much more complex rule on how the arguments to Fraction.__pow__ affect the type of the return value? At the moment, there are no known use cases for this change - beyond Neil's statement that he'd "like" the values to be as he quoted (with no justification given). > However the implementation for Fraction(-1) seems a bit to "ad hoc", and > break some expected behavior of the powers. > For exemple in your code Fraction(-2) ** Fraction(2, 3) != Fraction(-1) ** > Fraction(2, 3) * Fraction(2) ** Fraction(2, 3), whereas floats respect this. > You could change the code so that the property (a *b) ** c == a**c *b**c, > but idk how hard it is. > This (what behaviour is "expected" and/or natural) is the sort of detail that can't be answered without knowing use cases - both use cases for the proposed behaviour *and* use cases that rely on the existing behaviour. Paul
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/