Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:object': 0.07; 'python': 0.08; 'encoder': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; "hasn't": 0.13; 'subject:file': 0.13; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'unordered': 0.16; 'wrote:': 0.16; 'subject:skip:s 10': 0.18; 'help.': 0.18; 'suggest': 0.20; 'from:addr:web.de': 0.23; 'objects,': 0.23; 'developing': 0.25; 'module': 0.26; 'load': 0.26; "i'm": 0.27; 'problem': 0.29; 'efficiently': 0.30; 'far,': 0.30; '(e.g.': 0.30; 'url:library': 0.30; 'app': 0.31; 'version': 0.31; "isn't": 0.32; 'to:addr:python-list': 0.33; 'there': 0.33; 'force': 0.34; 'mostly': 0.34; 'anything': 0.34; 'flag': 0.34; 'numbers.': 0.34; 'stores': 0.34; 'header:X-Complaints-To:1': 0.34; 'subject:text': 0.35; 'file': 0.35; 'url:python': 0.36; 'but': 0.37; 'received:org': 0.37; 'easiest': 0.38; 'created': 0.38; 'possible.': 0.39; 'url:docs': 0.39; "i'd": 0.39; 'url:org': 0.39; 'subject:: ': 0.39; 'change': 0.40; 'might': 0.40; 'to:addr:python.org': 0.40; 'data': 0.40; 'course,': 0.61; 'kind': 0.62; 'texts': 0.73; 'database.': 0.74; 'dict,': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: stable object serialization to text file Date: Thu, 12 Jan 2012 13:24:32 +0100 Organization: None References: <030AD516-2A52-411B-9A20-BD60DF8AE75B@me.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Gmane-NNTP-Posting-Host: p5084b0fd.dip.t-dialin.net X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326371074 news.xs4all.nl 6871 [2001:888:2000:d::a6]:43384 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18874 Máté Koch wrote: > I'm developing an app which stores the data in file system database. The > data in my case consists of large python objects, mostly dicts, containing > texts and numbers. The easiest way to dump and load them would be pickle, > but I have a problem with it: I want to keep the data in version control, > and I would like to use it as efficiently as possible. Is it possible to > force pickle to store the otherwise unordered (e.g. dictionary) data in a > kind of ordered way, so that if I dump a large dict, then change 1 tiny > thing in it and dump again, the diff of the former and the new file will > be minimal? > > If pickle is not the best choice for me, can you suggest anything else? > (If there isn't any solution for it so far, I will write the module of > course, but first I'd like to look around and make sure it hasn't been > created yet.) Have you considered json? http://docs.python.org/library/json.html The encoder features a sort_keys flag which might help.