Skip to main content

Numpy data serialization using msgpack

Project description

Package Description

This package provides encoding and decoding routines that enable the serialization and deserialization of numerical and array data types provided by numpy using the highly efficient msgpack format. Serialization of Python's native complex data types is also supported.

Latest Version Build Status

Installation

msgpack-numpy requires msgpack-python and numpy. If you have pip installed on your system, run

pip install msgpack-numpy

to install the package and all dependencies. You can also download the source tarball, unpack it, and run

python setup.py install

from within the source directory.

Usage

The easiest way to use msgpack-numpy is to call its monkey patching function after importing the Python msgpack package:

import msgpack
import msgpack_numpy as m
m.patch()

This will automatically force all msgpack serialization and deserialization routines (and other packages that use them) to become numpy-aware. Of course, one can also manually pass the encoder and decoder provided by msgpack-numpy to the msgpack routines:

import msgpack
import msgpack_numpy as m
import numpy as np

x = np.random.rand(5)
x_enc = msgpack.packb(x, default=m.encode)
x_rec = msgpack.unpackb(x_enc, object_hook=m.decode)

msgpack-numpy will try to use the binary (fast) extension in msgpack by default.
If msgpack was not compiled with Cython (or if the MSGPACK_PUREPYTHON variable is set), it will fall back to using the slower pure Python msgpack implementation.

Notes

The primary design goal of msgpack-numpy is ensuring preservation of numerical data types during msgpack serialization and deserialization. Inclusion of type information in the serialized data necessarily incurs some storage overhead; if preservation of type information is not needed, one may be able to avoid some of this overhead by writing a custom encoder/decoder pair that produces more efficient serializations for those specific use cases.

Note that numpy arrays deserialized by msgpack-numpy are read-only and must be copied if they are to be modified.

Development

The latest source code can be obtained from GitHub.

Authors

See the included AUTHORS.md file for more information.

License

This software is licensed under the BSD License. See the included LICENSE.md file for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

msgpack-numpy-0.4.6.1.tar.gz (8.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

msgpack_numpy-0.4.6.1-py3.8.egg (8.0 kB view details)

Uploaded Egg

msgpack_numpy-0.4.6.1-py2.py3-none-any.whl (6.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file msgpack-numpy-0.4.6.1.tar.gz.

File metadata

  • Download URL: msgpack-numpy-0.4.6.1.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200712 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.1

File hashes

Hashes for msgpack-numpy-0.4.6.1.tar.gz
Algorithm Hash digest
SHA256 9f9b57abb2b155c2d3e411c2dd5b98f14998bd053a20c6ed0ab64a6ceb8ad51d
MD5 5d1d3e4dfe1c2d6b2bc05b91a2b5b7d0
BLAKE2b-256 d89a0f607b8b2e271b6e88482ad71021fde82eaefeb78fce3e86ec97bb5a9bc5

See more details on using hashes here.

File details

Details for the file msgpack_numpy-0.4.6.1-py3.8.egg.

File metadata

  • Download URL: msgpack_numpy-0.4.6.1-py3.8.egg
  • Upload date:
  • Size: 8.0 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200712 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.1

File hashes

Hashes for msgpack_numpy-0.4.6.1-py3.8.egg
Algorithm Hash digest
SHA256 031e83ae1b18cf3d1a44d34fe81aaf72d17ce8c37c031a5784f2b19d43ea63bb
MD5 463b5318d7c55e6b69fc8ec98c21f6c4
BLAKE2b-256 f952c7534a37f466bf10437e87ad7c98a4e1e59c4a73166797957ce184a18875

See more details on using hashes here.

File details

Details for the file msgpack_numpy-0.4.6.1-py2.py3-none-any.whl.

File metadata

  • Download URL: msgpack_numpy-0.4.6.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200712 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.1

File hashes

Hashes for msgpack_numpy-0.4.6.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 74b3e31f1ef1c81bf191d1265135198449f4cdd7d1153ee53f7fb2e107817f8e
MD5 2c926b55bacad96e21e8c1d3a284372b
BLAKE2b-256 ba508a49f3da7dca7baa9a5a12cd573af99b62746ba9298fa751e04a3c38c311

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page