Marshal Obj is String or Binary?

Giovanni Bajo noway at sorry.com
Sat Jan 14 07:11:29 EST 2006


Max wrote:

>>> What you see isn't always what you have. Your database is capable of
>>> storing \ x 0 0 characters, but your string contains a single byte
>>> of value zero. When Python displays the string representation to
>>> you, it escapes the values so they can be displayed.
>>
>>
>> He can still store the repr of the string into the database, and then
>> reconstruct it with eval:
>>
>
> Yes, but len(repr('\x00')) is 4, while len('\x00') is 1. So if he uses
> BLOB his data will take almost a quarter of the space, compared to
> your method (stored as TEXT).

Sure, but he didn't ask for the best strategy to store the data into the
database, he specified very clearly that he *can't* use BLOB, and asked how to
tuse TEXT.
-- 
Giovanni Bajo





More information about the Python-list mailing list