Python::Serialise::Pickle - a file for reading and writing pickled Python files


Python-Serialise-Pickle documentation  | view source Contained in the Python-Serialise-Pickle distribution.

Index


NAME

Top

Python::Serialise::Pickle - a file for reading and writing pickled Python files

SYNOPSIS

Top



    use Python::Serialise::Pickle;

    my $pr = Python::Serialise::Pickle->new("file/for/reading");
    while (my $data = $pr->load()) {
          print Dumper $data;
    }

    my $pw = Python::Serialise::Pickle->new(">file/for/writing");

    $pw->dump(['a' 'list']);
    $pw->dump("a string");
    $pw->dump(42);
    $pw->dump({'a'=>'hash'});

    $pw->close();  

DESCRIPTION

Top

Pickling is a method of serialising files in Python (another method, Marshalling, is also available).

This module is an attempt to write a pure Perl implementation of the algorithm.

METHODS

Top

new <filename>

Open a file for reading or writing. Can take any arguments that IO::File can.

load

Returns the next data structure from the pickle file or undef.

dump <data structure>

Takes a ref to an array or a hash or a number or string and pickles it.

Structures may be nested.

close

Closes the current file.

BUGS

Top

Almost certainly lots and lots.

Serialised objects

At the moment we don't deal with serialised objects very well. Should probably just take or return a Python::Serialise::Pickle::Object object.

The 'None' object

Similar to Perl's undef but an object. At the moment we deal with it badly because if we returned undef then that would signify the end of the Pickle file.

Should probably be returned as a special object or something.

Longs

There's no testing for longs

Unicode

Ditto

Some nested dictionaries

Dictionaries are the Python equivalent of hashes. This module can deal with most nested dictionaries but, for some reason, this one :

	a={'a':['two',{'goof':'foo', 'a':[1,2,3]}]}

causes it to fail.

Chnaging it slightly starts it working again.

Bad reading of specs

This is entirely my fault

ALTERNATIVES

Top

You could always dump the data structure out as YAML in Python and then read it back in with YAML in Perl.

AUTHOR

Top

Simon Wistow <simon@thegestalt.org>

COPYRIGHT

Top

SEE ALSO

Top

http://www.python.org, YAML, IO::File and the RESOURCES file in this distribution.


Python-Serialise-Pickle documentation  | view source Contained in the Python-Serialise-Pickle distribution.