Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: slow?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-06-21 (13:18)
From: Ruchira Datta <datta@m...>
Subject: Re: slow?

David Monniaux wrote:

> 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