caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Matt Harren" <matth@cs.berkeley.edu>
To: <caml-list@inria.fr>
Subject: [Caml-list] equality testing in 3.08
Date: Sun, 1 Aug 2004 18:54:05 -0700	[thread overview]
Message-ID: <200408020151.i721pCLL012876@relay0.EECS.Berkeley.EDU> (raw)

Hi,

I recently upgraded to OCaml 3.08, and ran into problems with the
changed implementation of structural equality.  To support NaN, the (=)
operator no longer checks for physical equality or its operands.  This
causes two problems:
  1) Our application runs 9% slower because comparison isn't as
efficient.  When x == y, checking "x = y" takes time proportional to the
size of the structure, instead of constant time.
  2) We've been cheating and using (=) on structures that may be cyclic.
This works fine on earlier versions of ocaml, because the structures
contain a unique identifier as their first field.  But now that
structural equality checks no longer begin with a physical equality
check, we can get an infinite loop.


To work around this, I've been defining
   let (=) x1 x2 : bool =
     (compare x1 x2) = 0
at the start of each file, since the "compare" function still starts
with a physical equality check.  Is there a better way to override a
definition in the Pervasives module?

Also, has there been any discussion of restoring the old meaning of (=)?
I know it breaks NaN, but the performance difference might make this
worthwhile, even if you have no sympathy for those of us who use = on
cyclic structures. :)


Thanks,
Matt


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


             reply	other threads:[~2004-08-02  1:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-02  1:54 Matt Harren [this message]
2004-08-02  9:50 ` Christophe TROESTLER

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200408020151.i721pCLL012876@relay0.EECS.Berkeley.EDU \
    --to=matth@cs.berkeley.edu \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).