Path: csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed6.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03; '(at': 0.03; 'elements.': 0.05; 'completeness': 0.07; 'json': 0.07; 'option,': 0.07; 'subject:application': 0.07; 'subject:file': 0.07; 'python': 0.09; 'compact': 0.09; 'port,': 0.09; 'received:155': 0.09; 'referencing': 0.09; 'sqlite': 0.09; 'subject:python': 0.11; "'a',": 0.16; "'b',": 0.16; "'c'": 0.16; "(can't": 0.16; '(either': 0.16; 'appreciated!': 0.16; 'benjamin': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'expandable': 0.16; 'from:addr:jpmorgan.com': 0.16; 'identifiers': 0.16; 'instances,': 0.16; 'module?': 0.16; 'pointers,': 0.16; 'portable,': 0.16; 'received:155.180': 0.16; 'received:155.180.234': 0.16; 'received:159.53': 0.16; 'received:169.70': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:svr.bankone.net': 0.16; 'securities,': 0.16; 'space)': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'wrote:': 0.17; 'duplicate': 0.17; 'items.': 0.17; '>>>': 0.18; 'subject:] ': 0.19; 'module': 0.19; 'to:name:python-list@python.org': 0.20; 'all,': 0.21; 'struct': 0.22; 'work.': 0.23; 'received:169.254': 0.24; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'guess': 0.27; 'scale': 0.27; 'accuracy': 0.27; 'converting': 0.27; 'easiest': 0.27; 'options': 0.27; 'subject:list': 0.28; 'pickle': 0.29; 'objects': 0.29; 'received:169': 0.29; 'probably': 0.29; 'class': 0.29; 'classes': 0.30; 'header:Received:8': 0.30; 'file': 0.32; 'structure': 0.32; 'problem': 0.33; 'to:addr:python-list': 0.33; 'built-in': 0.35; 'saved': 0.35; 'something': 0.35; 'but': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'data': 0.37; 'comment': 0.38; 'object': 0.38; 'sure': 0.38; 'advice': 0.39; 'to:addr:python.org': 0.39; 'easily': 0.39; 'subject:-': 0.40; 'think': 0.40; 'your': 0.60; 'different': 0.63; 'information,': 0.63; 'url:email': 0.63; 'other.': 0.64; 'legal': 0.65; 'subject': 0.66; 'purchase': 0.67; 'biggest': 0.71; 'sale': 0.76; 'application?': 0.84; 'compact,': 0.84; 'received:169.254.8': 0.84 X-DKIM: OpenDKIM Filter v2.1.3 sf1.jpmchase.com q8SKYuri019450 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1348864496; bh=DEIEa3P5abvd0GVBkbNB2i6WfQu+KTSBU9nDiQrgz2E=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=HNERer0C+5X9p2bB5wZeDrsaERhF7H7EKtfW7r4Hg3NK/ShjRBLclkeqTJrLIYDQZ C3CQ+NlbpTCzIYRyDQi9G17rtnGffFoNZvZ0JohmEu0xhuPI8hX5VnPy9nCjh5Iguk Oi4/6LD8shbniYuvHburcU2C0oJs8VMc+wal6pfA= From: "Prasad, Ramit" To: "python-list@python.org" Subject: RE: [python-list] python application file format Thread-Topic: [python-list] python application file format Thread-Index: AQHNm+bBRJQ3VHoSeEO2cs3jMnGtp5egNE9w Date: Fri, 28 Sep 2012 20:34:25 +0000 References: <5062F9D6.2060402@abzinc.com> In-Reply-To: <5062F9D6.2060402@abzinc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.67.79.47] Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-DLP-FWD: Yes Content-Type: text/plain; charset="us-ascii" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348864506 news.xs4all.nl 6884 [2001:888:2000:d::a6]:42589 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:30427 Benjamin Jessup wrote:=0D=0A> Hello all,=0D=0A> =0D=0A> What do people reco= mmend for a file format for a python desktop=0D=0A> application? Data is co= mplex with 100s/1000s of class instances, which=0D=0A> reference each other= =2E=0D=0A> =0D=0A> Write the file with struct module? (Rebuild object point= ers, safe,=0D=0A> compact, portable, not expandable without reserved space)= =0D=0A> =0D=0A> Use cPickle with a module/class whitelist? (Can't easily po= rt, not=0D=0A> entirely safe, compact enough, expandable)=0D=0A> =0D=0A> Us= e JSON or similar? (Rebuild object pointers, portable, expandable, size?)= =0D=0A> =0D=0A> Any advice is greatly appreciated!=0D=0A=0D=0AI would think= your options are pickle, json or database (either sqlite or =0D=0Asomethin= g like Postgres)=2E I am unfamiliar with the struct module so I =0D=0Acanno= t comment on its applicability=2E=0D=0A=0D=0AI would guess that your data w= ould be best saved by using a sqlite =0D=0Adatabase=2E Your biggest problem= might be how the different classes are =0D=0Areferencing each other=2E If = you are using identifiers then any of these =0D=0Aoptions will probably wor= k=2E If you are using aggregation then I know=0D=0Athat pickle will work (a= t least for built-in types)=2E JSON will=0D=0Akeep the structure but duplic= ate elements=2E=0D=0A=0D=0A=0D=0A>>> a =3D [ 1,2,3 ]=0D=0A>>> b =3D [ 'a', = 'b', 'c' ]=0D=0A>>> a=2Eappend( b )=0D=0A>>> e =3D [ a,b ]=0D=0A>>> s =3D j= son=2Edumps( e ) =0D=0A>>> eret =3D json=2Eloads( s )=0D=0A>>> id(eret[0][3= ]), id(eret[1]) # Same result for json and simplejson=0D=0A(329443808, 3276= 77272) =0D=0A>>> eret[0][3]=2Eappend( 'o')=0D=0A>>> eret[0][3], eret[1]=0D= =0A([u'a', u'b', u'c', 'o'], [u'a', u'b', u'c'])=0D=0A=0D=0ASo pickle will = be your easiest option, but I am not sure how well it=0D=0Awill scale with = a large number items=2E Using sqlite/db should scale well=0D=0Abut it will = take you longer/more effort to create a system for converting =0D=0Ayour ob= jects to and from the DB=2E=0D=0A=0D=0A=0D=0A=0D=0AThis email is confidenti= al and subject to important disclaimers and=0D=0Aconditions including on of= fers for the purchase or sale of=0D=0Asecurities, accuracy and completeness= of information, viruses,=0D=0Aconfidentiality, legal privilege, and legal = entity disclaimers,=0D=0Aavailable at http://www=2Ejpmorgan=2Ecom/pages/dis= closures/email=2E