From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA17124 for caml-red; Wed, 21 Jun 2000 15:18:56 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA11875 for ; Mon, 19 Jun 2000 19:30:51 +0200 (MET DST) Received: from math.berkeley.edu (gold.Math.Berkeley.EDU [169.229.58.61]) by nez-perce.inria.fr (8.10.0/8.10.0) with ESMTP id e5JHUof22922 for ; Mon, 19 Jun 2000 19:30:50 +0200 (MET DST) Received: from yuban-c.math.berkeley.edu (blue1.Math.Berkeley.EDU [169.229.58.58]) by math.berkeley.edu (8.9.3/8.9.3) with ESMTP id KAA07946; Mon, 19 Jun 2000 10:30:49 -0700 (PDT) Received: (from datta@localhost) by yuban-c.math.berkeley.edu (8.9.3/8.9.3) id KAA24321; Mon, 19 Jun 2000 10:30:49 -0700 (PDT) Date: Mon, 19 Jun 2000 10:30:48 -0700 From: Ruchira Datta To: caml-list@inria.fr Subject: Re: Pervasives.compare: slow? Message-ID: <20000619103048.A24283@math.berkeley.edu> Reply-To: datta@math.berkeley.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i Sender: weis@pauillac.inria.fr David Monniaux wrote: >Pervasives.compare is a polymorphic hack ... >There is apparently a 20-25% performance penalty using this form instead >of a simple comparison procedure for 16-byte strings. I suspect the >performance hit is even higher for more complex data structures. On p. 359 of _ML for the Working Programmer_, Paulson defines a function fun member (x:string, l) = List.exists (fn y => x=y) l; On the next page he says, "The functor declares function member for internal use.... The membership test is specific to type string because polymorphic equality can be slow." He seems to imply that in Standard ML, if the type of the things being compared is specified beforehand, then a type-specific comparison is used. I don't know if something similar holds in Objective Caml. Ruchira Datta datta@math.berkeley.edu