Code Monkey home page Code Monkey logo

python-pickle's Introduction

python-pickle

python-pickle is a Haskell library to serialize and deserialize Python objects using the Python Pickle format. It supports protocols 0, 1, and 2 for deserializing and uses protocol 2 for serialization.

It offers a Value data type to represent Python objects, and two functions, pickle and unpickle, to serialize and deserialize such values.

Implementation detail

In practice the Python Pickle format is a list of serialized opcodes. By deserializing those opcodes then interpreting them, one can reconstruct the original object. Interpreting the opcodes is done using a simple stack-based Pickle machine.

If you want to learn about the Pickle format, the standard Python pickletools library source is a good place to start.

Install

Installing from Hackage with Cabal is straightforward:

> cabal update ; cabal install python-pickle

The development version can be installed by cloning the Git repository and using Cabal:

> git clone git://github.com/noteed/python-pickle.git
> cd python-pickle && cabal install

Command-line tool

A pickle executable is provided. It can be used to inspect a pickle file (i.e. a file containing a pickled Python object).

Limitation

  • Not all opcodes are implemented.
  • Strings are not correctly escaped.
  • Can pickle (i.e. serialize) only with protocol 2.
  • Unpickling a protocol 0 string (which uses literal representation of e.g. float values) is not accurate (possibly the Python implementation is not accurate either).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.