|Sereal doesnt order the hash keys by default.||This can be enabled via the sort_keys, which is itself enabled by canonical option.|
|Sereal output is sensitive to refcounts||This can be somewhat mitigated by the use of canonical_refs, see above.|
|There are multiple valid Sereal documents that you can produce for the same Perl data structure.||
Just sorting hash keys is not enough. Some of the reasons
are outlined below. These issues are especially relevant when considering
Theres also a few cases where Sereal will produce different documents for values that you might think are the same thing, because if you e.g. compared them with eq or == in perl itself would think they were equivalent. However for the purposes of serialization theyre not the same value.
We might produce certain aggressive flags to the canonical mode in the future to deal with this. For the cases noted above some combination of turning the UTF-8 flag on on all strings, or stripping it from strings that have it but are ASCII-only would work, similarly we could scan strings to see if they match looks_like_number() and if so numify them.
This would produce output that either would be a lot bigger (having to encode all numbers as strings), or would be more expensive to generate (having to scan strings for numeric or non-ASCII context), and for some cases like the UTF-8 flag munging wouldnt be suitable for general use outside of canonicialization.
In a nutshell, the canonical option may be sufficient for an application which is simply serializing a cache key, and thus theres little harm in an occasional false-negative, but think carefully before applying Sereal in other use-cases.
Strings Or Numbers Perl does not make a strong distinction between strings and numbers, and from an internal point of view it can be difficult to tell what the right representation is for a given variable.
Sereal tries to not be lossy. So if it detects that the string value of a var, and the numeric value are different it will generally round trip the *string* value. This means that special strings often used in Perl function returns, like 0 but true, and 0e0, will round trip in a way that their normal Perl semantics are preserved. However this also means that non canonical values, like 100 , which will numify as 100 without warnings, will round trip as their string values.
Perl also has some operators, the binary operators, ^, | and &, which do different things depending on whether their arguments had been used in numeric context as the following examples show:
perl -lemy $x="1"; $i=int($x); print unpack "H*", $x ^ "1" 30 perl -lemy $x="1"; print unpack "H*", $x ^ "1" 00 perl -lemy $x=" 1 "; $i=int($x); print unpack "H*", $x ^ "1" 30 perl -lemy $x=" 1 "; print unpack "H*", $x ^ "1" 113120
Sereal currently cannot round trip this property properly.
An extreme case of this problem is that of dualvars, which can be created using the Scalar::Util::dualvar() function. This function allows one to create variables which have string and integer values which are completely unrelated to each other. Sereal currently will choose the *string* value when it detects these items.
It is possible that a future release of the protocol will fix these issues.
For reporting bugs, please use the github bug tracker at <http://github.com/Sereal/Sereal/issues>.
For support and discussion of Sereal, there are two Google Groups:
Announcements around Sereal (extremely low volume): <https://groups.google.com/forum/?fromgroups#!forum/sereal-announce>
Sereal development list: <https://groups.google.com/forum/?fromgroups#!forum/sereal-dev>
Yves Orton <firstname.lastname@example.org>
Steffen Mueller <email@example.com>
AEvar Arnfjoerd` Bjarmason <firstname.lastname@example.org>
Daniel Dragan <email@example.com> (Windows support and bugfixes)
Ivan Kruglov <firstname.lastname@example.org>
Some inspiration and code was taken from Marc Lehmanns excellent JSON::XS module due to obvious overlap in problem domain. Thank you!
This module was originally developed for Booking.com. With approval from Booking.com, this module was generalized and published on CPAN, for which the authors would like to express their gratitude.
Copyright (C) 2012, 2013, 2014 by Steffen Mueller Copyright (C) 2012, 2013, 2014 by Yves Orton
The license for the code in this distribution is the following, with the exceptions listed below:
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Except portions taken from Marc Lehmanns code for the JSON::XS module, which is licensed under the same terms as this module.
Also except the code for Snappy compression library, whose license is reproduced below and which, to the best of our knowledge, is compatible with this modules license. The license for the enclosed Snappy code is:
Copyright 2011, Google Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|perl v5.20.3||SEREAL::ENCODER (3)||2015-12-06|