XML vs. cPickle

Alan Kennedy alanmk at hotmail.com
Fri Jan 13 16:52:00 EST 2006

> I know XML is more (processor) costly than cPickle, but how bad is it?

Are you sure you know that?

I'd guess that XML serialisation with cElementTree is both cpu and 
memory competitive with cpickle, if not superior. Although I'm too lazy 
to fire up the timeit module right now :-)

Also, how quickly the relevant parsers work depends on the input, i.e. 
your data structures. Only you can take measurements with your data 
structures ....

> The idea is I want to store data that can be described as XML 

can != should

> into my
> database as cPickle objects. Except my web framework has no support for
> BLOB datatype yet, and I might have to go with XML.

Or you could encode the binary pickle in a text-safe encoding such as 
base64, and store the result in a text column. Although that will 
obviously increase your processing time, both going in and out of the 

> Ideas are appreciated,

I'd write a few simple prototypes and take some empirical measurements.


alan kennedy
email alan:              http://xhaus.com/contact/alan

More information about the Python-list mailing list