Object Serializer

20 views
Skip to first unread message

Victor Manuel Quiñones Victor

unread,
Oct 9, 2012, 9:10:25 PM10/9/12
to django...@googlegroups.com
Hi guys, I need some help here...

I need to serialize some objects and save them into the database. What library would you suggest for it?

Thank you

--
Quiñones Victor Manuel
Tel: +54 0362 15 4 880839
Resistencia - 3500
Argentina

Mike Dewhirst

unread,
Oct 9, 2012, 11:27:40 PM10/9/12
to django...@googlegroups.com
On 10/10/2012 12:10pm, Victor Manuel Qui�ones Victor wrote:
> Hi guys, I need some help here...
>
> I need to serialize some objects and save them into the database. What
> library would you suggest for it?

Have you looked at ...

https://docs.djangoproject.com/en/1.4/topics/serialization/


>
> Thank you
>
> --
> Qui�ones Victor Manuel
> Tel: +54 0362 15 4 880839
> Resistencia - 3500
> Argentina
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

Javier Guerra Giraldez

unread,
Oct 10, 2012, 9:40:02 AM10/10/12
to django...@googlegroups.com
On Tue, Oct 9, 2012 at 8:10 PM, Victor Manuel Quiñones Victor
<quinone...@gmail.com> wrote:
> I need to serialize some objects and save them into the database. What
> library would you suggest for it?

there are a few options, each with different pros/cons. roughly in
order of personal preference:

JSON:
pro: works in any language, easy to read
con: not the fastest, not the most compact

pickle:
pro: quite fast, easy and very transparent on Python
con: python only

messagepack:
pro: very fast, very compact
con: depends on a not-so-common library

glob:
pro: very fast, very compact
con: go only

protocolbuffers:
pro: quite fast, very compact, multi-version compatibility
con: not widespread, limited language support

tnetstrings:
pro: quite fast, compact, somewhat readable
con: not widespread

yaml:
pro: simple, readable, readable on many languages
con: not compact

XML:
pro: many utilities, many languages
con: no need to enumerate...


in practce, i'd say: if it's absolutely, definitely python only, and
there's some real speed/size concerns, use pickle. for almost
everything else, JSON

--
Javier
Reply all
Reply to author
Forward
0 new messages