Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18881
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!amsnews11.chello.com!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'json': 0.07; 'received:verizon.net': 0.07; 'subject:object': 0.07; 'terry': 0.07; 'python': 0.08; 'dict': 0.09; '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; ';-)': 0.12; 'am,': 0.12; "hasn't": 0.13; 'subject:file': 0.13; 'structures': 0.15; 'reedy': 0.16; 'unordered': 0.16; 'wrote:': 0.16; 'subject:skip:s 10': 0.18; 'help.': 0.18; 'convert': 0.19; 'jan': 0.19; 'suggest': 0.20; 'header:In-Reply-To:1': 0.22; 'objects,': 0.23; 'developing': 0.25; 'module': 0.26; 'load': 0.26; "i'm": 0.27; 'table,': 0.28; 'problem': 0.29; 'efficiently': 0.30; 'far,': 0.30; '(e.g.': 0.30; 'url:library': 0.30; 'app': 0.31; 'do.': 0.31; 'version': 0.31; 'does': 0.32; 'list': 0.32; "isn't": 0.32; 'header:User-Agent:1': 0.33; '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; 'another': 0.37; 'easiest': 0.38; 'created': 0.38; 'put': 0.38; 'should': 0.38; 'possible.': 0.39; 'url:docs': 0.39; "i'd": 0.39; 'url:org': 0.39; 'either': 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; 'you.': 0.64; 'texts': 0.73; 'database.': 0.74; 'dict,': 0.84; 'otten': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: stable object serialization to text file |
| Date | Thu, 12 Jan 2012 15:15:54 -0500 |
| References | <030AD516-2A52-411B-9A20-BD60DF8AE75B@me.com> <jemjde$98u$1@dough.gmane.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | quoted-printable |
| X-Gmane-NNTP-Posting-Host | pool-74-109-121-73.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 |
| In-Reply-To | <jemjde$98u$1@dough.gmane.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4691.1326399385.27778.python-list@python.org> (permalink) |
| Lines | 47 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1326399385 news.xs4all.nl 6843 [2001:888:2000:d::a6]:56634 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:18881 |
Show key headers only | View raw
On 1/12/2012 7:24 AM, Peter Otten wrote: > 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. If that does not do it for you, consider that a dict is a two-column table, with arbitrary structures in each column. Convert to list with sorted(somedict.items()). This is basically what json should do. Then write to a text stream, one line per key,value pair. Whether you put the text into an os file in a directory (a hierachical database ;-) or a text field in another database is up to you. Either way, diffs are easy. -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: stable object serialization to text file Terry Reedy <tjreedy@udel.edu> - 2012-01-12 15:15 -0500
csiph-web