Pickle - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Pickle (.pkl) File Format

Pickle file format

Description

 • Pickle is a binary file format for storing arbitrary Python data.
 • The general-purpose commands Import and Export support this format.
 • Export accepts any input which is accepted by convert/python.
 • Import produces an expression of type python.
 • Note that this file format is not secure. It is possible to construct malicious pickle data which will execute arbitrary code on import. It should therefore only be used with trusted data.

Examples

Encode a matrix as a pickle expression.

 > $\mathrm{pickledmatrix}≔\mathrm{convert}\left(⟨⟨1,2⟩|⟨3,4⟩⟩,\mathrm{ByteArray},\mathrm{format}="Pickle"\right)$

Import a pickled expression from a file.

 > $\mathrm{Import}\left("example/address.pkl",\mathrm{base}=\mathrm{datadir}\right)$
 ${table}{}\left(\left[{"founded"}{=}{1988}{,}{"companyName"}{=}{"Maplesoft"}{,}{"phoneNumbers"}{=}\left[{""}{,}{""}{,}{""}\right]{,}{"address"}{=}{table}{}\left(\left[{"country"}{=}{"Canada"}{,}{"postalCode"}{=}{"N2V 1K8"}{,}{"province"}{=}{"ON"}{,}{"city"}{=}{"Waterloo"}{,}{"streetAddress"}{=}{"615 Kumpf Drive"}\right]\right)\right]\right)$ (1)

Import the same data, but as a python  expression.

 > $\mathrm{Import}\left("example/address.pkl",\mathrm{base}=\mathrm{datadir},\mathrm{output}=\mathrm{python}\right)$
 ${""}$ (2)