Serialization

    Write an arbitrary value to a stream in an opaque format, such that it can be read back by . The read-back value will be as identical as possible to the original, but note that values are serialized as all-zero bit patterns (NULL).

    An 8-byte identifying header is written to the stream first. To avoid writing the header, construct a and use it as the first argument to serialize instead. See also Serialization.writeheader.

    The data format can change in minor (1.x) Julia releases, but files written by prior 1.x versions will remain readable. The main exception to this is when the definition of a type in an external package changes. If that occurs, it may be necessary to specify an explicit compatible version of the affected package in your environment. Renaming functions, even private functions, inside packages can also put existing files out of sync. Anonymous functions require special care: because their names are automatically generated, minor code changes can cause them to be renamed. Serializing anonymous functions should be avoided in files intended for long-term storage.

    In some cases, the word size (32- or 64-bit) of the reading and writing machines must match. In rarer cases the OS or architecture must also match, for example when using packages that contain platform-dependent code.

    Julia 1.1

    This method is available as of Julia 1.1.

    — Function

    Read a value written by serialize. assumes the binary data read from stream is correct and has been serialized by a compatible implementation of . is designed for simplicity and performance, and so does not validate the data read. Malformed data can result in process termination. The caller must ensure the integrity and correctness of data read from stream.

    Julia 1.1

    This method is available as of Julia 1.1.

    Serialization.writeheader — Function

    Write an identifying header to the specified serializer. The header consists of 8 bytes as follows: