On Fri, May 14, 2021 at 04:58:08PM -0000, Martin Teichmann wrote:

> Could I please see an example? This is a real question, by now I ran 
> my prototyped interpreter through quite some libraries, and none made 
> problems like this.

Any script or application that does calculations and formats them for 
display to the user which uses print() or equivalent string formatting 
such as `%s` etc will suddenly start producing output like this:

    Fraction(3135227393067235, 17592186044416)

instead of the expected output:

    178.217043928

Any library that uses doctests will also suffer similar issues.


> Real world examples I am talking about. Sure, I can easily code an 
> approximation for pi which goes out of hand quickly, but doing this in 
> Python would be just wrong unless you are writing a text book.

An approximation to pi accurate to 15 decimal places is just 
Fraction(884279719003555, 281474976710656), which calculates almost 
instantly and takes only 48 bytes:

    >>> sys.getsizeof(Fraction(math.pi))
    48

plus another 64 bytes for the numerator and denominator ints themselves.


-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/BGHD63AI4ETGY2BBKV43C6CNHYOLBG3H/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to