PDL::IO::Storable3pm
Helper functions to make pdl usable with serialisation packages
Usage
use Storable;use PDL::IO::Storable;$hash = {'foo' => 42,'bar' => zeroes(23,45),};store $hash, 'perlhash.dat';use JSON::MaybeXS;$encoder = JSON::MaybeXS->new(allow_tags => 1);my $ndarray = xvals (5,2);my $encoded_json = $encoder->encode ($ndarray);my $decoded_ndarray = $encoder->decode ($encoded_json);
Overview
Serialisation packages such as "Storable", "Sereal", "JSON::MaybeXS" and "CBOR::XS" implement object persistence for Perl data structures that can contain arbitrary Perl objects. This module implements the relevant methods to be able to store and retrieve ndarrays via "Storable" as well as packages that support the Types::Serialiser protocol (currently Sereal, CBOR::XS and JSON packages).
Note that packages supporting the "Types::Serialiser" protocol need to have their respective flags enabled so that the FREEZE and THAW callbacks are used.
Note also that while JSON::MaybeXS is supported, if it has to fall back to JSON::PP, it will fail. JSON::XS treats the data it gets back from "FREEZE" as items to encode, while JSON::PP treats the list it gets as strings already encoded. They are fundamentally incompatible, so this module supports the JSON::XS option.
Finally, data flow is not preserved. If a data structure containing ndarrays connected by data flow is serialised then this will need to be explicitly reinstated on deserialisation.
Functions
store
store an ndarray using Storable
$x = random 12,10;$x->store('myfile');
freeze
freeze an ndarray using Storable
$x = random 12,10;$frozen = $x->freeze;
Releases
11 releases since Debian 3.1 (Sarge); the text changed 10 times.