[Haskell-cafe] Optimizing Eq instances with reallyUnsafePtrEquality#
cdsmith at gmail.com
Tue Jun 8 14:32:24 UTC 2021
I have definitely done this before in situations where equality comparison
is unusually expensive, such as when it involves walking a tree. It hasn't
caused any problems, and I choose to believe that it helped a bit. That
said, I have never measured the effect, so I'm interested if anyone has a
principled way of quantifying the performance gain. My solution to the
problem of irreflexive equality was just to not care about it... YMMV on
whether that's okay for your use case!
On Tue, Jun 8, 2021 at 10:27 AM Simon Jakobi via Haskell-Cafe <
haskell-cafe at haskell.org> wrote:
> Hi everyone!
> we're wondering whether certain Eq instances, for example record types
> or strings, could be optimized by including a pointer equality check
> that detects when an object is compared with itself.
> Does anyone here have experience with such an optimization? Has this
> been considered before, for example in GHC's deriving machinery?
> One complication seems to be the correct handling of fields with
> irreflexive instances, for example Float and Double. In such a case,
> pointer equality doesn't imply "==-equality".
> I'm looking forward to hearing your thoughts on this! :)
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe