From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id BAA16673; Tue, 4 Mar 2003 01:40:09 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 BAA17173 for ; Tue, 4 Mar 2003 01:40:07 +0100 (MET) Received: from mallaury.noc.nerim.net (smtp-102.noc.nerim.net [62.4.17.102]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h240drH26962 for ; Tue, 4 Mar 2003 01:39:59 +0100 (MET) Received: from karryall.dnsalias.org (karryall.dnsalias.org [62.4.18.180]) by mallaury.noc.nerim.net (Postfix) with ESMTP id E281E62D01; Tue, 4 Mar 2003 01:39:49 +0100 (CET) Received: by karryall.dnsalias.org (Postfix, from userid 500) id 1E5321A0022; Tue, 4 Mar 2003 01:39:52 +0100 (CET) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15971.62935.981249.585423@karryall.dnsalias.org> Date: Tue, 4 Mar 2003 01:39:51 +0100 To: Issac Trotts Cc: caml-list@inria.fr From: Olivier Andrieu Subject: Re: [oliver: Re: [Caml-list] Strings as arrays or lists...] In-Reply-To: <3E63F13E.4090303@ucdavis.edu> References: <20030303182806.GC624@first.in-berlin.de> <20030303210554.GA5245@force.stwing.upenn.edu> <3E63F13E.4090303@ucdavis.edu> X-Mailer: VM 7.07 under Emacs 21.2.1 X-Spam: no; 0.00; andrieu:01 oliver:01 caml-list:01 issac:01 trotts:01 char:01 tradeoff:01 arrays:01 irrelevant:01 toplevel:01 olivier:02 string:03 allocate:03 let:04 array:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Issac Trotts [Monday 3 March 2003] : > Char arrays take up four times as much space as strings, but there is a > tradeoff > of space versus time. The statement > > let a = Array.make 2000000 ' ';; > > takes no noticable time, but > > let s = String.make 2000000 ' ';; > > takes about 7 seconds to run on my computer. Er ... what are you talking about ? If you're talking about the toplevel, that's completely irrelevant because what takes time then is merely the _printing_ of the value. Strings are printed entirely by the toplevel (not very smart for long strings), whereas only the first values of arrays are printed. String.make and Array.make still do the same thing : allocate some space and fill it with an initial value. But array of chars take up four times as much space and thus it usually takes longer to allocate such a big array. -- Olivier ------------------- 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