python pickle size limit

怎甘沉沦 提交于 2019-12-10 17:19:54

问题


i want to pickle a large (1810392*255) numpy array. However when pickling i get an error:

[...]error: 'i' format requires -2147483648 <= number <= 2147483647

Code:

import numpy
import pickle
l=numpy.zeros((1810392,255))
f=open('file.pkl','wb')
pickle.dump(l,f,2)

Is there a size limit? Is there a workaround? If not necessary I do not want to use hdf5 or something not build into python.

I also tried numpy.savez and numpy.savez_compressed. Code:

import numpy
l=numpy.zeros((1810392,255))
numpy.savez_compressed('file.npz',l)

Saving works but when i try to load the data I get an error. Code:

import numpy
l=numpy.load('file.npz')
l['arr_0']

I need to use numpy.savez instead of numpy.save because I want to store additional data.

来源:https://stackoverflow.com/questions/17298129/python-pickle-size-limit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!