Pickle is more for storing complex objects (arrays, dict, etc). pickling a
string makes it bigger.

I have stored large text chunks in text and/or blob columns compressed with
gzip.zlib.compress and extracted with gzip.zlib.decompress

Comparison:

import cPickle as Pickle
import gzip

x = "asdfasdfasdfasdfasdfasdfasdfasdfasdf"

print len(x)
>> 36

print len(Pickle.dumps(x))
>> 44

print len(gzip.zlib.compress(x))
>> 14


Vince

On Wed, Jun 24, 2009 at 11:17 AM, Dinesh B Vadhia <dineshbvad...@hotmail.com
> wrote:

>  I want to pickle (very long) strings and save them in a sqlite db.  The
> plan is to use pickle dumps() to turn a string into a pickle object and
> store it in sqlite.  After reading the string back from the sqlite db, use
> pickle loads() to turn back into original string.
>
> - Is this a good approach for storing very long strings?
>
> - Are the pickle'd strings stored in the sqlite db as a STRING or BLOB?
>
> Cheers.
>
> Dinesh
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to