Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > RE: [python-list] python application file format

Reply
Thread Tools

RE: [python-list] python application file format

 
 
Prasad, Ramit
Guest
Posts: n/a
 
      09-28-2012
Benjamin Jessup wrote:

> Hello all,
>
> What do people recommend for a file format for a python desktop
> application? Data is complex with 100s/1000s of class instances, which
> reference each other.
>
> Write the file with struct module? (Rebuild object pointers, safe,
> compact, portable, not expandable without reserved space)
>
> Use cPickle with a module/class whitelist? (Can't easily port, not
> entirely safe, compact enough, expandable)
>
> Use JSON or similar? (Rebuild object pointers, portable, expandable, size?)
>
> Any advice is greatly appreciated!


I would thinkyour options are pickle, json or database (either sqlite or
something like Postgres). I am unfamiliar with the struct module so I
cannot comment on its applicability.

I would guess that your data would be best saved by using a sqlite
database. Your biggest problemmight be how the different classes are
referencing each other. If you are using identifiers then any of these
options will probably work. If you are using aggregation then I know
that pickle will work (at least for built-in types). JSON will
keep the structure but duplicate elements.



>>> a = [ 1,2,3 ]
>>> b = [ 'a', 'b', 'c' ]
>>> a.append( b )
>>> e = [ a,b ]
>>> s = json.dumps( e )
>>> eret = json.loads( s )
>>> id(eret[0][3]), id(eret[1]) # Same result for json and simplejson

(329443808, 327677272)

>>> eret[0][3].append( 'o')
>>> eret[0][3], eret[1]

([u'a', u'b', u'c', 'o'], [u'a', u'b', u'c'])

So pickle will be your easiest option, but I am not sure how well it
will scale with a large number items. Using sqlite/db should scale well
but it will take you longer/more effort to create a system for converting
your objects to and from the DB.



This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completenessof information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.
 
Reply With Quote
 
 
 
 
Ramchandra Apte
Guest
Posts: n/a
 
      09-29-2012
On Saturday, 29 September 2012 02:05:07 UTC+5:30, Prasad, Ramit wrote:
> Benjamin Jessup wrote:
>
> > Hello all,

>
> >

>
> > What do people recommend for a file format for a python desktop

>
> > application? Data is complex with 100s/1000s of class instances, which

>
> > reference each other.

>
> >

>
> > Write the file with struct module? (Rebuild object pointers, safe,

>
> > compact, portable, not expandable without reserved space)

>
> >

>
> > Use cPickle with a module/class whitelist? (Can't easily port, not

>
> > entirely safe, compact enough, expandable)

>
> >

>
> > Use JSON or similar? (Rebuild object pointers, portable, expandable, size?)

>
> >

>
> > Any advice is greatly appreciated!

>
>
>
> I would think your options are pickle, json or database (either sqlite or
>
> something like Postgres). I am unfamiliar with the struct module so I
>
> cannot comment on its applicability.
>
>
>
> I would guess that your data would be best saved by using a sqlite
>
> database. Your biggest problem might be how the different classes are
>
> referencing each other. If you are using identifiers then any of these
>
> options will probably work. If you are using aggregation then I know
>
> that pickle will work (at least for built-in types). JSON will
>
> keep the structure but duplicate elements.
>
>
>
>
>
> >>> a = [ 1,2,3 ]

>
> >>> b = [ 'a', 'b', 'c' ]

>
> >>> a.append( b )

>
> >>> e = [ a,b ]

>
> >>> s = json.dumps( e )

>
> >>> eret = json.loads( s )

>
> >>> id(eret[0][3]), id(eret[1]) # Same result for json and simplejson

>
> (329443808, 327677272)
>
> >>> eret[0][3].append( 'o')

>
> >>> eret[0][3], eret[1]

>
> ([u'a', u'b', u'c', 'o'], [u'a', u'b', u'c'])
>
>
>
> So pickle will be your easiest option, but I am not sure how well it
>
> will scale with a large number items. Using sqlite/db should scale well
>
> but it will take you longer/more effort to create a system for converting
>
> your objects to and from the DB.
>
>
>
>
>
>
>
> This email is confidential and subject to important disclaimers and
>
> conditions including on offers for the purchase or sale of
>
> securities, accuracy and completeness of information, viruses,
>
> confidentiality, legal privilege, and legal entity disclaimers,
>
> available at http://www.jpmorgan.com/pages/disclosures/email.


Guess I shouldn't read or rely your posts (virus'es could be in them)
 
Reply With Quote
 
 
 
 
Ramchandra Apte
Guest
Posts: n/a
 
      09-29-2012
On Saturday, 29 September 2012 02:05:07 UTC+5:30, Prasad, Ramit wrote:
> Benjamin Jessup wrote:
>
> > Hello all,

>
> >

>
> > What do people recommend for a file format for a python desktop

>
> > application? Data is complex with 100s/1000s of class instances, which

>
> > reference each other.

>
> >

>
> > Write the file with struct module? (Rebuild object pointers, safe,

>
> > compact, portable, not expandable without reserved space)

>
> >

>
> > Use cPickle with a module/class whitelist? (Can't easily port, not

>
> > entirely safe, compact enough, expandable)

>
> >

>
> > Use JSON or similar? (Rebuild object pointers, portable, expandable, size?)

>
> >

>
> > Any advice is greatly appreciated!

>
>
>
> I would think your options are pickle, json or database (either sqlite or
>
> something like Postgres). I am unfamiliar with the struct module so I
>
> cannot comment on its applicability.
>
>
>
> I would guess that your data would be best saved by using a sqlite
>
> database. Your biggest problem might be how the different classes are
>
> referencing each other. If you are using identifiers then any of these
>
> options will probably work. If you are using aggregation then I know
>
> that pickle will work (at least for built-in types). JSON will
>
> keep the structure but duplicate elements.
>
>
>
>
>
> >>> a = [ 1,2,3 ]

>
> >>> b = [ 'a', 'b', 'c' ]

>
> >>> a.append( b )

>
> >>> e = [ a,b ]

>
> >>> s = json.dumps( e )

>
> >>> eret = json.loads( s )

>
> >>> id(eret[0][3]), id(eret[1]) # Same result for json and simplejson

>
> (329443808, 327677272)
>
> >>> eret[0][3].append( 'o')

>
> >>> eret[0][3], eret[1]

>
> ([u'a', u'b', u'c', 'o'], [u'a', u'b', u'c'])
>
>
>
> So pickle will be your easiest option, but I am not sure how well it
>
> will scale with a large number items. Using sqlite/db should scale well
>
> but it will take you longer/more effort to create a system for converting
>
> your objects to and from the DB.
>
>
>
>
>
>
>
> This email is confidential and subject to important disclaimers and
>
> conditions including on offers for the purchase or sale of
>
> securities, accuracy and completeness of information, viruses,
>
> confidentiality, legal privilege, and legal entity disclaimers,
>
> available at http://www.jpmorgan.com/pages/disclosures/email.


Guess I shouldn't read or rely your posts (virus'es could be in them)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: python application file format Dieter Maurer Python 0 09-27-2012 06:55 AM
[python-list] python application file format Benjamin Jessup Python 2 09-26-2012 01:01 PM
Splitting a multirecord per file format to a single record per file format: Right approach? Randy Kramer Ruby 2 01-12-2007 06:46 PM
print dos format file into unix format PengYu.UT@gmail.com Python 5 10-27-2006 01:56 PM
convert different video format (avi,mpeg,mp4, etc) file to a flash format solomon_13000@yahoo.com C++ 1 09-11-2006 06:15 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57