[Python-ideas] Approximately equal operator

Nathaniel Smith njs at pobox.com
Fri Jun 15 20:31:57 EDT 2018

On Fri, Jun 15, 2018 at 3:56 PM, Andre Roberge <andre.roberge at gmail.com> wrote:
> * people doing heavy numerical work and wanting code as readable as possible

IME serious numerical work doesn't use approximate equality tests at
all, except in test assertions.

> * teaching mostly beginners about finite precision for floating point
> arithmetics

Given that approximate equality tests are almost never the right
solution, I would be worried that emphasizing them to beginners would
send them down the wrong path. This is already a common source of
confusion and trap for non-experts.

> * people wishing to have trigonometric functions with arguments in degrees,
> as in a current discussion on this forum.

AFAICT approximate equality checks aren't really useful for that, no.
(I also don't understand why people in that argument are so worried
about exact precision for 90° and 30° when it's impossible for all the
other angles.)

Python is *very* stingy with adding new operators; IIRC only 3 have
been added over the last ~30 years (**, //, @). I don't think ~= is
going to make it.


Nathaniel J. Smith -- https://vorpus.org

More information about the Python-ideas mailing list