pickling large objects

3 years ago by lntl to c/python

I have a large object that I want to save to the disk because it takes a minute to generate. The OOM reaper kills the process while pickle.dump ing the object.

It's a tuple of dicts of tuple of array.array.

Can pickle dump in chunks? If not, is there another technique I can use?

load all comments
alehc 5 points 3 years ago

You mean numpy arrays? I think the most efficient way to store them is via np.save. You could try creating a new directory and store all of your arrays there with clever file naming to retrieve the dictionary structure later.

Alternatively if you are up to trying to use pytorch you can convert the arrays to tensors and use torch.save to save the entire dictionary in one file. Installing pytorch just for this might be a bit overkill as it is a >1GB installation tho.

path: 0 27184, hotness: undefined, score: 5, children: 2
lntl 2 points 3 years ago

It's a tuple of dicts of tuples of array.array, no numpy or torch :(

path: 0 27184 27399, hotness: undefined, score: 2, children: 1
alehc 3 points 3 years ago

So python standard library lists?

path: 0 27184 27399 27523, hotness: undefined, score: 3, children: 0
python

@lemmy.ml

login for more options
3652
109
4

News and discussions about the programming language Python


go to feed...