<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Aug 30, 2018 at 9:03 AM Steven D'Aprano <<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Aug 29, 2018 at 09:39:05PM -0700, Neil Girdhar wrote:<br>
<br>
> Would there be any problem with changing:<br>
> <br>
> In [4]: Fraction(1, 1) ** Fraction(2, 3)<br>
> Out[4]: 1.0<br>
> <br>
> In [5]: Fraction(-1, 1) ** Fraction(2, 3)<br>
> Out[5]: (-0.4999999999999998+0.8660254037844387j)<br>
> <br>
> In [6]: Fraction(0, 1) ** Fraction(2, 3)<br>
> Out[6]: 0.0<br>
> <br>
> I'd like these to be Fraction(1), Fraction(1), and Fraction(0).<br>
<br>
If anyone else has mentioned the backward-compatibility issue by now, I <br>
haven't see it. I believe that would make it a fairly big problem.<br>
<br></blockquote><div><br></div><div>I don't think it's that big a problem since Fraction < numbers.Real</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I expect that there is code out in the wild which (for good or ill) now <br>
expects 1**Fraction(2, 3) to return 1.0, rather than Fraction(1), and <br>
similarly for the other examples. Changing that could break people's <br>
code.<br>
<br>
Even if we had consensus that this was a good idea, or at least <br>
consensus from the maths-folk who care about this sort of thing (I'd <br>
like to know what Uncle Timmy and Mark think of this idea), it would <br>
still probably need a "__future__" import to activate it, or a <br>
deprecation period. Or some other annoyance.<br>
<br>
Possibly the simpler approach would be to add a subclass that does what <br>
you want. UnitRootFraction or something.<br>
<br>
Then the only argument will be whether such a subclass ought to go into <br>
the fractions module, or your own personal toolkit :-)<br>
<br>
I must admit though, I'm a bit curious as to what you are doing that <br>
having 1**Fraction(2,3) return 1.0 is an annoyance, but having <br>
27**Fraction(2,3) return 8.999999999999998 instead of Fraction(9) isn't.<br>
<br></blockquote><div>You're right, it would have been better in my example (linked above) to support all of those things. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
-- <br>
Steve<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
<br>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group.<br>
To unsubscribe from this topic, visit <a href="https://groups.google.com/d/topic/python-ideas/aZIHpPhe0mw/unsubscribe" rel="noreferrer" target="_blank">https://groups.google.com/d/topic/python-ideas/aZIHpPhe0mw/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href="mailto:python-ideas%2Bunsubscribe@googlegroups.com" target="_blank">python-ideas+unsubscribe@googlegroups.com</a>.<br>
For more options, visit <a href="https://groups.google.com/d/optout" rel="noreferrer" target="_blank">https://groups.google.com/d/optout</a>.<br>
</blockquote></div></div>