Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/noteed/python-pickle
Serialization/deserialization using Python Pickle format
https://github.com/noteed/python-pickle
Last synced: about 2 months ago
JSON representation
Serialization/deserialization using Python Pickle format
- Host: GitHub
- URL: https://github.com/noteed/python-pickle
- Owner: noteed
- License: other
- Created: 2012-12-31T18:02:25.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2024-02-10T06:11:22.000Z (11 months ago)
- Last Synced: 2024-10-28T14:19:03.858Z (2 months ago)
- Language: Haskell
- Size: 46.9 KB
- Stars: 15
- Watchers: 4
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# python-pickle
python-pickle is a Haskell library to serialize and deserialize Python objects
using the Python Pickle format. It supports protocols 0-5 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).