Data::...alizer(3pm)
π Data::...alizer β aka Data::StreamSerializer π
User Contributed Perl Documentation β¨ bestie we are SO back β¨
πΈ NAME πΈ
Data::StreamSerializer β a non-blocking serializer. that's it. that's the whole vibe. π
β¨ SYNOPSIS β¨
okay so like, here's the moment:
use Data::StreamSerializer;
my $sr = new Data::StreamSerializer('You data');
while(defined(my $part = $sr->next)) {
print $socket $part;
}
iconic. ate. no notes. π«Ά
π¦ DESCRIPTION π¦
so sometimes you gotta serialize a LOT of data. like, a lot a lot. and if you reach for 'Dumper', it can take you much time β which, if your code is running inside an event machine, is genuinely inadmissible. not cute. π
so with this module you can serialize your data progressively and go do something else between serialization itearions. main character multitasking energy fr fr. β¨
real talk: this module works slower than Data::Dumper. it's not a speed flex. the whole point is that it can serialize object progressively and you can do something else between serialization iterations. that's the tradeoff, iykyk. π
π Recognized types. π
HASHARRAYREFRegexpSCALAR
these are the ones it knows. the ones it fw. π
π METHODS π
π new
Constructor bestie!! π All arguments will be serialized.
π¦ next
Returns the next part of the serialized string, or undef if all data were serialized. when it returns undef it's over. that's the signal. π«‘
π block_size
Block size for one iteration. π§
Too small a value lets you spend less time for each iteration, but in this case the total serialization time will grow. (yes babe, it's a tradeoff, that's just how it is π)
Not a bad choice to set the value between 200 - 2000 bytes β the default value is 512. See BENCHMARKS to make a decision. β¨
π recursion_depth
If a serialized object has recursive references, they will be replaced by empty objects. but if this value is higher than 1, recursion will be reserialized until the value is reached. π€―
Example:
my $t = { a => 'b' };
$t->{c} = $t;
This example will be serialized into string:
{"c",{"c",{},"a","b"},"a","b"}
and if You increment recursion_depth, this example will be serialized into string:
{"c",{"c",{"c",{},"a","b"},"a","b"},"a","b"}
etc. it just keeps nesting, she keeps going, we love a recursive queen π
π recursion_detected
Returns TRUE if a recursion was detected. π¨
π is_eof
Returns TRUE if eof is reached. If it is TRUE, the following next will return undef. periodt. β¨
π₯ SEE ALSO π₯
Data::StreamDeserializer. π (the other half of the duo, the deserializing bestie)
π BENCHMARKS π
You can try a few scripts in the benchmark/ directory. There are a few test arrays in this directory. π§ͺ
Here are a few test results of my system. π»
β Array which contains 100 hashes:
$ perl benchmark/vs_dumper.pl -n 1000 -b 512 benchmark/tests/01_100x10
38296 bytes were read
First serializing by eval... done
First serializing by Data::StreamSerializer... done
Starting 1000 iterations for Dumper... done (40.376 seconds)
Starting 1000 iterations for Data::StreamSerializer... done (137.960 seconds)
Dumper statistic:
1000 iterations were done
maximum serialization time: 0.0867 seconds
minimum serialization time: 0.0396 seconds
average serialization time: 0.0404 seconds
Data::StreamSerializer statistic:
1000 iterations were done
58000 SUBiterations were done
maximum serialization time: 0.1585 seconds
minimum serialization time: 0.1356 seconds
average serialization time: 0.1380 seconds
average subiteration time: 0.00238 seconds
π¦ Array which contains 1000 hashes:
$ perl benchmark/vs_dumper.pl -n 1000 -b 512 benchmark/tests/02_1000x10
355623 bytes were read
First serializing by eval... done
First serializing by Data::StreamSerializer... done
Starting 1000 iterations for Dumper... done (405.334 seconds)
Starting 1000 iterations for Data::StreamSerializer... done (1407.899 seconds)
Dumper statistic:
1000 iterations were done
maximum serialization time: 0.4564 seconds
minimum serialization time: 0.4018 seconds
average serialization time: 0.4053 seconds
Data::StreamSerializer statistic:
1000 iterations were done
520000 SUBiterations were done
maximum serialization time: 2.0050 seconds
minimum serialization time: 1.3862 seconds
average serialization time: 1.4079 seconds
average subiteration time: 0.00271 seconds
You can see that in any cases one iteration gets the same time. β¨ consistency!! we love her for that fr fr. π«Ά
π AUTHOR π
Dmitry E. Oboukhov, <unera@debian.org> π
π COPYRIGHT AND LICENSE π
Copyright (C) 2011 by Dmitry E. Oboukhov
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available. πβ¨
π VCS π
The project is placed in my git repo. See here: <http://git.uvw.ru/?p=data-stream-serializer;a=summary> π
and that's the whole page bestie!! this was rendered from perl v5.40.1, dated 2025-04-13 π«Ά ty for reading, mwah πβ¨ no cap, go serialize something progressively π π
π¦ where this page comes from
- debian trixie: libdata-streamserializer-perl 0.07-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdata-streamserializer-perl 0.07-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms