Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
92 lines (56 sloc) 2.43 KB


Sereal - A binary serialization format


This repository is the home of the Sereal data serialization format. This format was started because the authors had technical reasons for producing a better Storable.

Before we embarked on this project we had a look at various prior art. This included a review of Google Protocol Buffers and of the MessagePack protocol. Neither suited our needs so we designed this, liberally borrowing ideas from the other projects.




We wanted to be able serialize shared references properly. Many serialization formats do not support this out of the box.

Weak References

Perl has the concept of a special type of reference called a "weakref" which is used to create cyclic reference structures which do not leak memory. We need to handle these structures.


Perl supports aliases which are a special kind of reference which is effectively a C level pointer instead of a Perl level RV. We needed to be able to represent these as well.


Blessing a reference can be dangerous in some circumstances. We needed to be able to serialize objects safely and reliably, and we wanted a sane control mechanism for doing so.

Regexp Objects

In Perl, a regexp is a native type. We wanted to be able serialize these at a native level without losing data such as modifiers.

Space Efficiencies

We want to be able to represent common structures as small as is reasonable. Although not to the extreme that this makes the protocol error prone. This includes such thing as removing redundancy from the serialized structure (such as hash keys or classnames) automatically.

Speed Efficiencies

We want to be able to serialize and deserialize quickly. Some of the design decisions and trade-offs were aimed squarely at performance.

Separate Decoder and Encoder

We wanted to separate the functions of serializing from deserializing so they could be upgraded independently.

Forward/Backward Compatibility

We wanted the protocol to be robust to forward/backwards compatibility issues. It should be possible to partially read new formats with an old decoder, and possibly output old formats with a new decoder.


Yves Orton <>

Damian Gryski

Steffen Mueller <>

Rafaël Garcia-Suarez

Ævar Arnfjörð Bjarmason

Jump to Line
Something went wrong with that request. Please try again.