From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id B9A85BC0A for ; Wed, 20 Jun 2007 12:24:55 +0200 (CEST) Received: from bdmail1.accesst.com (pop.bulldoghome.com [83.245.1.230]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5KAOtPX028268 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Wed, 20 Jun 2007 12:24:55 +0200 Received: from host-84-9-232-172.bulldogdsl.com ([84.9.232.172] helo=[192.168.123.191]) by bdmail1.accesst.com with esmtpa (Exim 4.50) id 1I0xFx-00010X-M3; Wed, 20 Jun 2007 11:17:46 +0100 Message-ID: <46790128.6090104@ed.ac.uk> Date: Wed, 20 Jun 2007 11:27:52 +0100 From: Jeremy Yallop User-Agent: Mozilla-Thunderbird 2.0.0.4 (X11/20070618) MIME-Version: 1.0 To: Joel Reymont Cc: Caml List Subject: Re: [Caml-list] ANN: pretty-printing, type-safe marshalling, dynamic typing for free. References: <46787172.4080404@ed.ac.uk> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 46790077.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.01; type-safe:01 marshalling:01 marshalling:01 sexp:01 mutable:01 fwiw:01 20,:98 2007,:98 shelves:98 007:98 003:98 003:98 012:98 equality:01 arbitrary:01 Joel Reymont wrote: > > On Jun 20, 2007, at 1:14 AM, Jeremy Yallop wrote: > >> Serialisation (marshalling): >> >> Shelve.shelveS points >> => >> "\007\003\t\128\128\128\128\128\128\128\248?\t\128\128\128\128\128\128\128\128@\001\000\005\000\001\008\000\001\n\001\003\004\t\003\000\001\012\001\003\006\011\005\005\002\002\000\002\000\002\002\000\000\002\001\001\002\002\002" >> > > Aha! Now I can implement a Sexp library for 3.10! > > What is the difference between pickling and shelving, though? In `deriving' Pickle is a fairly naive value-oriented serialiser. It doesn't do any structure sharing: the same value can be repeated several times in the output. It doesn't preserve cycles, so it's not available for mutable values. You can customize Pickle by writing your own definition for a particular type. Shelve handles cycles correctly and minimises values so the output is potentially much smaller. It also provides a different means of specialization: by giving a custom definition of equality for a type you can increase opportunities for sharing. It's currently rather slow for large values, but I expect that to change in the next release. Shelve is built on top of Pickle, FWIW. The choice of names is pretty arbitrary: I wrote Pickle first, then I needed another name when I wrote Shelve. Jeremy.