Questions tagged [pickle]

Pickle is an object serialization module for Python. Use this tag together with the Python tag for questions related to storing or loading objects with Pickle.

Pickle provides a powerful set of tools for serializing and de-serializing Python objects.

4936 questions
2
votes
1 answer

cPickle: UnpicklingError: invalid load key, 'A'

I have a pickle file which upon unpickling throws an UnpicklingError: invalid load key, 'A'. exception. The exception gets thrown regardless of whether I try to analyse it on the Ubuntu 14.04 machine on which the file was generated or on my Windows…
P-M
  • 1,279
  • 2
  • 21
  • 35
2
votes
2 answers

Can cPickle save reshaped numpy object reference?

I have a class defined as: class A(): def __init__(): self.a = np.array([0,1,2,3,4,5]) self.b = self.a.reshape((2, 3)) now, b is in fact a reshaped reference of array a. If we change the first element of a:a[0] = 10, b[0, 0]…
maple
  • 1,828
  • 2
  • 19
  • 28
2
votes
1 answer

Using PicklingTools with QT Creator

I'm trying to use the latest version of PicklingTools (http://www.picklingtools.com/) with QT Creator. I just want to open a pickled sample file that I downloaded together with the PicklingTools files. So my main.cpp file looks very basic: #include…
rbu
  • 43
  • 1
  • 4
2
votes
1 answer

Dumping pickle is not working with rb+

Why pickle file is not modified? But after I uncomment the line it works? with open(PATH, "rb+") as fp: mocks_pickle = pickle.load(fp) mocks_pickle['aa'] = '123' # pickle.dump(mocks_pickle, open(PATH, 'wb')) pickle.dump(mocks_pickle,…
HereHere
  • 734
  • 1
  • 7
  • 24
2
votes
2 answers

Deserialisation "pickle" file

My code is: import _pickle with open('items_10000_matrix.pickle', 'rb') as f: data_new = _pickle.load(f) But an error occurs: UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 212: ordinal not in range(128) I am using…
user6557479
2
votes
1 answer

Best way to save/load list of strings and the file will be manipulated by two Python scripts at the same time

I will create two Python scripts. One will generate strings and save them to a file. The other will traverse through the list of string from the top down, do operations on each string and then delete the string when done. I would like to know which…
Khoi Tran
  • 37
  • 3
2
votes
0 answers

How to edit saved plots by pickle?

I want to save and edit plots generated by matplotlib (not image file, prefer editable file). I used the pickle package and I can save and open a plot by following code. #------------- #save code #------------- import matplotlib.pyplot as…
user6695701
  • 197
  • 1
  • 10
2
votes
1 answer

pickle.dump blocks the main thread in multithreaded python application because of GIL

Currently I'm using python 3.4.3 and developing PyQt5 application. In my app, there's a QThread, and some large object(100MB) is being (pickle) dumped by the thread. However, dumping that object requires 1~2 seconds, and it blocks the main thread…
asqdf
  • 289
  • 2
  • 9
2
votes
1 answer

How to dump `sklearn.neighbors.KDTree` object to hdf5?

According to document of sklearn.neighbors.KDTree, we may dump KDTree object to disk with pickle. However, it's very slow for both dumping and loading, and storage comsuming. Is it possible to dump it to hdf5 format?
Syrtis Major
  • 3,791
  • 1
  • 30
  • 40
2
votes
1 answer

Interaction between pathos.ProcessingPool and pickle

I have a list of calculations I need to run. I'm parallelizing them using from pathos.multiprocessing import ProcessingPool pool = ProcessingPool(nodes=7) values = pool.map(helperFunction, someArgs) helperFunction does create a class called…
FooBar
  • 15,724
  • 19
  • 82
  • 171
2
votes
1 answer

In SQLAlchemy is it possible to dump and load from a Table (not from a mapped class)?

TL;DR Using SQLAlchemy is it possible to do a dumps(…) and load(…) using a Table (not a mapped class)? Just to clarify, I wrote those two tiny tests (currently red) to make my point. Having this mapped class and session: from sqlalchemy import…
cuducos
  • 730
  • 6
  • 17
2
votes
1 answer

Hdf5 and pickle takes more space than raw csv file

I have a csv file (containing only numeric data) of size 18 MB. When I read it and convert to numpy array and save it in hdf5 format or pickle , it takes around 48 MB disk space. Shouldn't the data be compressed when we use pickle or hdf5? Is it…
Himaprasoon
  • 2,609
  • 3
  • 25
  • 46
2
votes
0 answers

Python3 Pickle hitting recursion limit

I have the following block of code that when executed on my Ubuntu computer using Python3 hits the recursion error for pickling. I don't understand why since the object to be pickled is not particularly complex and doesn't involve any custom…
2
votes
0 answers

Why must you pickle Matplotlib figure before saving to file, not vice versa?

I've noticed that I cannot pickle a matplotlib figure after saving it as an image, whether as png, jpeg, or pdf. Why is this the case? Is there a clean way around this if a workflow calls for saving as png, then later as a pickle? I'm using…
NPMitchell
  • 193
  • 1
  • 10
2
votes
1 answer

Array List of Lists Python

Hi I'm following a tutorial where they use the MNIST database. Now they use the cPickle to unzip the data and get a tuple of list and so on. I want to use my own data but I have it on csv format and I'm not sure how to convert to the MNIST format. I…
Ellebkey
  • 2,201
  • 3
  • 22
  • 31
1 2 3
99
100