Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent to pickle in Julia

I'm looking for a convenient way to dump and load variables in Julia, just like pickle does in Python.

Is there a package which does something like myVar = load(myPath) and dump(myVar, myPath) (or similarly f = open(myPath, "r"); myVar = load(f)) ?

like image 237
P. Camilleri Avatar asked Mar 31 '15 08:03

P. Camilleri


People also ask

What can I use instead of a pickle in Python?

An alternative is cPickle. It is nearly identical to pickle , but written in C, which makes it up to 1000 times faster. For small files, however, you won't notice the difference in speed. Both produce the same data streams, which means that Pickle and cPickle can use the same files.

What is faster than pickle Python?

quickle is a fast and small serialization format for a subset of Python types. It's based off of Pickle, but includes several optimizations and extensions to provide improved performance and security. For supported types, serializing a message with quickle can be ~2-10x faster than using pickle .

Why are pythons called Pickles?

Is there a history about it? "Pickling" is process which enables storage and preservation. "Pickle" is "Pickle" because "Python" is "Python".

Is pickle only for Python?

As mentioned above, the pickle module is Python-specific, and the result of a pickling process can be read only by another Python program.


2 Answers

HDF5.jl package have been split into HDF5 new package and JLD

see here: https://github.com/JuliaLang/JLD.jl

Saving and loading julia variables while preserving native types is now possible using JLD

According doc:

JLD, for which files conventionally have the extension .jld, is a widely-used format for data storage with the Julia programming language. JLD is a specific "dialect" of HDF5, a cross-platform, multi-language data storage format most frequently used for scientific data. By comparison with "plain" HDF5, JLD files automatically add attributes and naming conventions to preserve type information for each object.

like image 138
scls Avatar answered Oct 22 '22 15:10

scls


I think the HDF5 package has the functionality you want, it worked very good for me using some custom types and all:

see here:

https://github.com/JuliaLang/HDF5.jl

like image 26
skariel Avatar answered Oct 22 '22 15:10

skariel