On 05/08/2019 0:04, Jeroen Demeyer wrote:
> On 2019-07-27 18:49, 'Mark Bell' via sage-devel wrote:
>> During Sage Days 100, I experienced an issue with Sage's Integers and
>> Rational not being compatible with Python's built in Fraction class.
>> This made me unable to run my Python code within Sage
>
> It would be good to explain better exactly what kind of code you were
> running and why this is an issue for you.
>
> I mentioned this issue to the Python devs and Guido van Rossum basically
> rejected the problem. He literally said "what real-world problem does
> that solve?" when talking about letting Python fractions interoperate
> with Sage fractions, see
>
https://discuss.python.org/t/pep-3141-ratio-instead-of-numerator-denominator/2037/27?u=jdemeyer
>
Not with Fraction, but I think I encountered something similar with
num.real() and num.imag(). IIRC, it was for plotting a simple function
that used either the methods real() and imag() or the properties, and it
obviously required a fix. Something like:
sage: plot(lambda x: x.imag + 2) # Works
sage: plot(lambda x: x.imag() + 2, (x, -3, 3)) # Empty plot
In other words, I agree with Vincent at
https://discuss.python.org/t/pep-3141-ratio-instead-of-numerator-denominator/2037/6
To add another data point about triggering unexpected computations,
numpy.array does have .real and .imag properties.
>
> If this would be a simple bugfix, I would dismiss Guido's comment as
> irrelevant. But in this case, there is no easy fix. Every proposed fix
> is somewhat backwards incompatible and can potentially break stuff. So
> we should only apply a fix if it will actually solve a real problem that
> people are encountering.
Regards,
TB