Efficient serialization across system images

I’ve got a dictionary containing only String keys mapping to Numbers. This is the result of a computation that runs on a server. Since I make use of PyJulia to initiate the computation from a Python app, I’m using a custom system image (like mentioned here).

This comes with the problem, that I cannot properly read (using Serialization.deserialize(...)) the result using my local Julia after downloading the binary file. (Documented here: Serialization · The Julia Language)

Is there any other way to efficiently serialize something like that into a file that can be shared across Julia installations? I know I could just write that Dict to a file myself, but I was kind of expecting there to be something semi-stable for “easy” data types.

As far as I know, there is no “semi-stable” serialization mechanism in Base, unfortunately.

If an extra dependency is not a problem, then MsgPack is simple:

From the docs:

julia> bytes = pack(["hello", Dict(:this => 1, ['i', 's'] => 3.14, "messagepack!" => nothing)])
42-element Array{UInt8,1}:

In your case I think even JSON may be a good choice.

1 Like

Thanks for pointing me to MsgPack, didn’t know that one and that will be helpful!