3 ms·
One example is if an and b are arrays (e.g. numpy arrays) it’s not unreasonable for dunder eq to return an array of booleans. Another example might be if you h
by datsci_est_2015 5mo ago
One example is if an and b are arrays (e.g. numpy arrays) it’s not unreasonable for dunder eq to return an array of booleans.
Another example might be if you have a domain specific representation of equality (e.g. class Equality)
- voidUpdate 5mo agoI can see the first one making sense, but why would you need a representation of equality other than "yes, these are equal" and "no, these are not equal"?
- datsci_est_2015 5mo agoWell personally I’m not a fan of turning everything into an object, but if you have properties or methods that exist upon the concept of Equality you might want to encode directly onto a class. Maybe in a domain where “Equality” is an important concept, like mathematics or even something like accounting. Could enable a different interface into approximate equality for floating point numbers: Equality.approximate(iota: float) -> bool
- agons 5mo agoThe first use case that comes to mind is if you want a DSL to build expressions that are evaluated later in some different context e.g. when using `polars`: ```python df.filter( pl.col("foo") == pl.col("bar"), ) ``` Sqlalchemy does something equivalent too, and I'm sure there are many others.