Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit b4d0344

Browse files
author
ariddell
committed
DOC: add reminder to use pickle.HIGHEST_VERSION
Earlier protocol versions of pickle are limited in the amount of data they can serialize into a single file. Closes #197
1 parent 4098464 commit b4d0344

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

doc/differences_pystan_rstan.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ Python:
6666
fit = model.sampling(data=data)
6767
6868
with open('model.pkl', 'wb') as f:
69-
pickle.dump(model, f)
69+
pickle.dump(model, f, protocol=pickle.HIGHEST_PROTOCOL)
7070
7171
# load it at some future point
72-
7372
with open('model.pkl', 'rb') as f:
7473
model = pickle.load(f)
7574
7675
# run with different data
7776
fit = model.sampling(data=dict(N=5, y=[1, 1, 0, 1, 0]))
7877
78+
7979
R:
8080

8181
.. code-block:: r
@@ -86,3 +86,7 @@ R:
8686
save(model, file='model.rdata')
8787
8888
See also :ref:`avoiding-recompilation`.
89+
90+
If you are saving a large amount of data with ``pickle.dump``, be sure to use
91+
the highest protocol version available. Earlier versions are limited in the
92+
amount of data they can save in a single file.

0 commit comments

Comments
 (0)