压缩序列化模块 [英] compressed serialization module
问题描述
我使用了pickle,发现文件以文本格式保存。我想知道
是否有人熟悉一个很好的紧凑型现成模块
可用,它将以压缩格式保存...或者可能是一个意见
采用智能方法制作定制产品?欣赏它!我是一个n00b的b $ b,但一直在寻找。我发现了一个serialize.py
但它似乎有点矫枉过正。
Mark
2008年11月17日上午10:47,Mark写道:
我使用了pickle,发现文件以文本格式保存。我想知道
是否有人熟悉一个很好的紧凑型现成模块
可用,它将以压缩格式保存...或者可能是一个意见
采用智能方法制作定制产品?
嗯,这里有一个想法:创建一个zip文件(使用标准的zip文件
模块),并将你的数据腌制成。
HTH,
- Joe
>我使用了pickle,发现文件以文本格式保存。我想知道是否有人熟悉一个可以保存为压缩格式的良好紧凑型现成模块......或者可能是一个关于定制智能方法的意见
一?
JoeWell,这里有一个想法:创建一个zip文件(使用标准的
Joezipfile模块)和pickle你的数据。
另外,指定一个pickle二进制protool。这是一个愚蠢的例子:
>> len(pickle.dumps([ 1,2,3],pickle.HIGHEST_PROTOCOL))
14
< blockquote class =post_quotes>
>> len(pickle.dumps([1,2,3],0))
18
Skip
sk ** @ pobox.com < sk ** @ pobox.comwrote:
>
>我使用了pickle,发现文件以文本格式保存。我想知道
>是否有人熟悉一个很好的紧凑型现成模块
>可以保存为压缩格式...或者可能是一个意见
>关于制作定制产品的智能方法?
JoeWell,这里有一个想法:创建一个zip文件(使用标准的
Joezipfile模块)和pickle你的数据。
另外,指定一个pickle二进制protool。这是一个愚蠢的例子:
>> len(pickle.dumps([1,2,3],pickle .HIGHEST_PROTOCOL))
14
> ;> len(pickle.dumps([1,2,3],0))
18
甚至
>> L =范围(100 )
a = pickle.dumps(L)
len(a)
496
>> b = a.encode(" bz2")
len(b )
141
>> c = b.decode(" bz2")
M = pickle.loads(c)
M == L
True
> ;>>
-
Nick Craig-Wood< ni ** @ craig-wood.com- - http://www.craig-wood.com/nick
I used pickle and found the file was saved in text format. I wonder
whether anyone is familiar with a good compact off-the-shelf module
available that will save in compressed format... or maybe an opinion
on a smart approach for making a custom one? Appreciate it! I''m a
bit of a n00b but have been looking around. I found a serialize.py
but it seems like overkill.
Mark
On Nov 17, 2008, at 10:47 AM, Mark wrote:
I used pickle and found the file was saved in text format. I wonder
whether anyone is familiar with a good compact off-the-shelf module
available that will save in compressed format... or maybe an opinion
on a smart approach for making a custom one?Well, here''s a thought: create a zip file (using the standard zipfile
module), and pickle your data into that.
HTH,
- Joe
>I used pickle and found the file was saved in text format. I wonder
whether anyone is familiar with a good compact off-the-shelf module
available that will save in compressed format... or maybe an opinion
on a smart approach for making a custom one?
JoeWell, here''s a thought: create a zip file (using the standard
Joezipfile module), and pickle your data into that.
Also, specify a pickle binary protool. Here''s a silly example:
>>len(pickle.dumps([1,2,3], pickle.HIGHEST_PROTOCOL))
14
>>len(pickle.dumps([1,2,3], 0))
18
Skip
sk**@pobox.com <sk**@pobox.comwrote:>>I used pickle and found the file was saved in text format. I wonder
>whether anyone is familiar with a good compact off-the-shelf module
>available that will save in compressed format... or maybe an opinion
>on a smart approach for making a custom one?
JoeWell, here''s a thought: create a zip file (using the standard
Joezipfile module), and pickle your data into that.
Also, specify a pickle binary protool. Here''s a silly example:
>>len(pickle.dumps([1,2,3], pickle.HIGHEST_PROTOCOL))
14
>>len(pickle.dumps([1,2,3], 0))
18
Or even
>>L = range(100)
a = pickle.dumps(L)
len(a)
496
>>b = a.encode("bz2")
len(b)
141
>>c = b.decode("bz2")
M = pickle.loads(c)
M == L
True
>>>
--
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
这篇关于压缩序列化模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!