From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id BB8F7BC32 for ; Wed, 16 Mar 2005 14:10:12 +0100 (CET) Received: from ryxa.irisa.fr (ryxa.irisa.fr [131.254.50.45]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j2GDACZB018245 for ; Wed, 16 Mar 2005 14:10:12 +0100 Received: (from pad@localhost) by ryxa.irisa.fr (8.11.6/8.11.6) id j2GDA9H13605; Wed, 16 Mar 2005 14:10:09 +0100 X-Authentication-Warning: ryxa.irisa.fr: pad set sender to padiolea@irisa.fr using -f Sender: pad@ryxa.irisa.fr To: Jon Harrop Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] OCaml troll on Slashdot References: <42363A86.6010309@1969.ws> <172f01077499b3d417604d0ad31f2bdb@cs.unm.edu> <20050316001819.GB347@first.in-berlin.de> <200503160301.11138.jon@ffconsultancy.com> From: Yoann Padioleau Date: 16 Mar 2005 14:10:09 +0100 In-Reply-To: <200503160301.11138.jon@ffconsultancy.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Miltered: at nez-perce with ID 42383034.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 irisa:01 imho:01 associative:01 associative:01 ocaml's:01 hashtbl:01 hashtbl:01 hash:01 memoizing:01 okasaki:01 oliver:01 bandel:01 recursive:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: Jon Harrop writes: > Just for the record, I'd like to dispell a couple of myths: > > On Wednesday 16 March 2005 01:05, Yoann Padioleau wrote: > > IMHO the reason it was slow is because it used associative list (instead of > > Map) for associative access, > > Although Map is asymptotically faster than List.assoc for lookup (O(ln n) vs > O(n)), OCaml's Hashtbl and array-based equivalents are typically several > times faster than Map. I agree, I beleived that too but I switched from Map to Hashtbl in the "troll" code and Hashtbl sux. I don't know why. > Also, I think that many people would consider the use of an imperative data > structure, such as a hash table, for memoizing to be the remit of functional > programming. I do. As much as possible I try to have "persistent" (persistent in the okasaki sense) data-structures. > > On Wednesday 16 March 2005 00:18, Oliver Bandel wrote: > > which does not really looks tail recursive. > > Called more than 2 * 10^6 times... > > And many other examples... > > In OCaml, non-tail-recursive functions are often faster than their tail > recursive equivalents for small inputs (e.g. short lists). really ? why ? > I expect that the > functions you have identified fall into this category, so converting them to > tail-recursive form is likely to slow the program down rather than speed it > up. -- Yoann Padioleau, INSA de Rennes, France www.irisa.fr/prive/padiolea/ Opinions expressed here are only mine. Je n'écris qu'à titre personnel. **____ Get Free. Be Smart. Simply use Linux and Free Software. ____**