相关疑难解决方法(0)

用python 3.5安装cPickle

这可能很傻但我无法安装cPicklepython 3.5 docker镜像

Dockerfile

FROM python:3.5-onbuild
Run Code Online (Sandbox Code Playgroud)

requirements.txt

cpickle
Run Code Online (Sandbox Code Playgroud)

当我尝试构建图像时

$ docker build -t sample .
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM python:3.5-onbuild
# Executing 3 build triggers...
Step 1 : COPY requirements.txt /usr/src/app/
Step 1 : RUN pip install --no-cache-dir -r requirements.txt
 ---> Running in 016c35a032ee
Collecting cpickle (from -r requirements.txt (line 1))
  Could not find a version that satisfies the requirement cpickle (from -r requirements.txt (line 1)) (from versions: )
No …
Run Code Online (Sandbox Code Playgroud)

python pickle docker python-3.5

33
推荐指数
2
解决办法
6万
查看次数

marshal转储速度更快,cPickle加载速度更快

我正在实现一个需要序列化和反序列化大对象的程序,所以我正在进行一些测试pickle,cPicklemarshal选择模块来选择最佳模块.一路上我发现了一些非常有趣的东西:

我正在使用dumps然后loads(对于每个模块)列表中的dicts,元组,整数,浮点数和字符串.

这是我的基准测试的输出:

DUMPING a list of length 7340032
----------------------------------------------------------------------
pickle => 14.675 seconds
length of pickle serialized string: 31457430

cPickle => 2.619 seconds
length of cPickle serialized string: 31457457

marshal => 0.991 seconds
length of marshal serialized string: 117440540

LOADING a list of length: 7340032
----------------------------------------------------------------------
pickle => 13.768 seconds
(same length?) 7340032 == 7340032

cPickle => 2.038 seconds
(same length?) 7340032 == 7340032

marshal => 6.378 seconds
(same …
Run Code Online (Sandbox Code Playgroud)

python performance serialization

18
推荐指数
4
解决办法
1万
查看次数

标签 统计

python ×2

docker ×1

performance ×1

pickle ×1

python-3.5 ×1

serialization ×1