msgpack Documentation

Similar documents
Dogeon Documentation. Release Lin Ju

json-rpc Documentation

pybdg Documentation Release 1.0.dev2 Outernet Inc

python-ipfix Documentation

WordEmbeddingLoader Documentation

streamio Documentation

mprpc Documentation Release Studio Ousia

tolerance Documentation

LECTURE 20. Serialization and Data Persistence

OstrichLib Documentation

redis-lua Documentation

python-lz4 Documentation

Python Working with files. May 4, 2017

Python Essential Reference, Second Edition - Chapter 5: Control Flow Page 1 of 8

Files. Files need to be opened in Python before they can be read from or written into Files are opened in Python using the open() built-in function

ADVENTURE_IO Input/Output format and libraries for ADVENTURE modules List of Input/Output Functions February 17, 2006

pyvcd Documentation Release Peter Grayson and Steven Sprouse

Beyond Blocks: Python Session #1

Kaiso Documentation. Release 0.1-dev. onefinestay

kafka-python Documentation

Python 3000 and You. Guido van Rossum PyCon March 14, 2008

asn1tools Documentation

Lecture 21. Programming with Subclasses

datastream Documentation

Lecture 21. Programming with Subclasses

pylatexenc Documentation

solrq Documentation Release Michał Jaworski

Advanced Python. Executive Summary, Session 1

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

CSC148 Fall 2017 Ramp Up Session Reference

pyprika Documentation

DaMPL. Language Reference Manual. Henrique Grando

python-rapidjson Documentation

JSONRPC Documentation

Python 3000 and You. Guido van Rossum EuroPython July 7, 2008

Sherlock Documentation

Control Structures 1 / 17

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

B.V. Patel Institute of BMC & IT, UTU 2014

prompt Documentation Release Stefan Fischer

mayatools Documentation

Single Source Python 2 3

Techniques of Java Programming: Streams in Java

CIS192 Python Programming. Robert Rand. August 27, 2015

django-crucrudile Documentation

PYTHON FOR KIDS A Pl ayfu l I ntrodu ctio n to Prog r am m i ng J a s o n R. B r i g g s

Manticore Documentation

Avpy Documentation. Release sydh

py-couchdb Documentation

TH IRD EDITION. Python Cookbook. David Beazley and Brian K. Jones. O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Tokyo

Python Overpass API Documentation

python-unrar Documentation

obfuscator Documentation

pymemcache Documentation

Final Exam Version A

CSC Java Programming, Fall Java Data Types and Control Constructs

Review 3. Exceptions and Try-Except Blocks

Pypeline Documentation

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

tld Documentation Release 0.9 Artur Barseghyan

edeposit.amqp.antivirus Release 1.0.1

Python INTRODUCTION: Understanding the Open source Installation of python in Linux/windows. Understanding Interpreters * ipython.

The WSGI Reference Library

py3o.template Documentation

Introduction to pysqlite

StratumGS Documentation

Lecture 18. Classes and Types

Lecture 21. Programming with Subclasses

Connexion Documentation

RPLidar Documentation

python-anyvcs Documentation

Sequence types. str and bytes are sequence types Sequence types have several operations defined for them. Sequence Types. Python

Programming in Python 3

Basic I/O - Stream. Java.io (stream based IO) Java.nio(Buffer and channel-based IO)

ISO-8583 SDK (3.50) Copyright (C) by AZS Services , Dec, 2015

New York University School of Continuing and Professional Studies Management and Information Technology. Advanced Python. Homework, Session 5

Ertza Documentation. Release Benoit Rapidel, ExMachina

pynput Release

CIS192 Python Programming

django-redis-cache Documentation

PYTHON MOCK TEST PYTHON MOCK TEST III

MyGeotab Python SDK Documentation

Python. Executive Summary

CIS192 Python Programming

CIS192 Python Programming

GIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes

CIS192 Python Programming

I/O streams. Byte Streams Character Streams InputStream ByteArrayInputStream FileInputStream FilterInputStream

Short Notes of CS201

Marshmallow-Mongoengine Documentation

Using Type Annotations in Python. by Philippe Fremy / IDEMIA

Good Luck! CSC207, Fall 2012: Quiz 1 Duration 25 minutes Aids allowed: none. Student Number:

CS201 - Introduction to Programming Glossary By

iptools Release dev

Python Mock Tutorial Documentation

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

GitHub-Flask Documentation

UTORid: Lecture Section: (circle one): L0101 (MWF10) L0201 (MWF11) Instructor: Jacqueline Smith Jen Campbell

RM0327 Reference manual

Cross-platform daemonization tools.

Transcription:

msgpack Documentation Release 0.4 Author 2017-11-04

Contents 1 API reference 3 Python Module Index 9 i

ii

MessagePack is a efficient format for inter language data exchange. Contents 1

2 Contents

CHAPTER 1 API reference msgpack.pack(o, stream, **kwargs) Pack object o and write it to stream See Packer for options. dump() is alias for pack() msgpack.packb(o, **kwargs) Pack object o and return packed bytes See Packer for options. dumps() is alias for packb() msgpack.unpack(stream, object_hook=none, list_hook=none, bool use_list=1, encoding=none, unicode_errors= strict, object_pairs_hook=none, ext_hook=exttype, Py_ssize_t max_str_len=2147483647, Py_ssize_t max_bin_len=2147483647, Py_ssize_t max_array_len=2147483647, Py_ssize_t max_map_len=2147483647, Py_ssize_t max_ext_len=2147483647) Unpack an object from stream. Raises ValueError when stream has extra bytes. See Unpacker for options. load() is alias for unpack() msgpack.unpackb(packed, object_hook=none, list_hook=none, bool use_list=1, encoding=none, unicode_errors= strict, object_pairs_hook=none, ext_hook=exttype, Py_ssize_t max_str_len=2147483647, Py_ssize_t max_bin_len=2147483647, Py_ssize_t max_array_len=2147483647, Py_ssize_t max_map_len=2147483647, Py_ssize_t max_ext_len=2147483647) Unpack packed_bytes to object. Returns an unpacked object. Raises ValueError when packed contains extra bytes. See Unpacker for options. loads() is alias for unpackb() 3

class msgpack.packer(default=none, encoding= utf-8, unicode_errors= strict, use_single_float=false, bool autoreset=1, bool use_bin_type=0, bool strict_types=0) MessagePack Packer usage: packer = Packer() astream.write(packer.pack(a)) astream.write(packer.pack(b)) Packer s constructor has some keyword arguments: Parameters default (callable) Convert user type to builtin type that Packer supports. See also simplejson s document. encoding (str) Convert unicode to bytes with this encoding. (default: utf-8 ) unicode_errors (str) Error handler for encoding unicode. (default: strict ) use_single_float (bool) Use single precision float type for float. (default: False) autoreset (bool) Reset buffer after each pack and return its content as bytes. (default: True). If set this to false, use bytes() to get content and.reset() to clear buffer. use_bin_type (bool) Use bin type introduced in msgpack spec 2.0 for bytes. It also enables str8 type for unicode. strict_types (bool) If set to true, types will be checked to be exact. Derived classes from serializeable types will not be serialized and will be treated as unsupported type and forwarded to default. Additionally tuples will not be serialized as lists. This is useful when trying to implement accurate serialization for python types. bytes(self ) Return buffer content. pack(self, obj) pack_array_header(self, long long size) pack_ext_type(self, typecode, data) pack_map_header(self, long long size) pack_map_pairs(self, pairs) Pack pairs as msgpack map type. pairs should be a sequence of pairs. (len(pairs) and for k, v in pairs: should be supported.) reset(self ) Clear internal buffer. class msgpack.unpacker(file_like=none, Py_ssize_t read_size=0, bool use_list=1, object_hook=none, object_pairs_hook=none, list_hook=none, encoding=none, unicode_errors= strict, int max_buffer_size=0, ext_hook=exttype, Py_ssize_t max_str_len=2147483647, Py_ssize_t max_bin_len=2147483647, Py_ssize_t max_array_len=2147483647, Py_ssize_t max_map_len=2147483647, Py_ssize_t max_ext_len=2147483647) Streaming unpacker. arguments: Parameters 4 Chapter 1. API reference

file_like File-like object having.read(n) method. If specified, unpacker reads serialized data from it and feed() is not usable. read_size (int) Used as file_like.read(read_size). (default: min(1024**2, max_buffer_size)) use_list (bool) If true, unpack msgpack array to Python list. Otherwise, unpack to Python tuple. (default: True) object_hook (callable) When specified, it should be callable. Unpacker calls it with a dict argument after unpacking msgpack map. (See also simplejson) object_pairs_hook (callable) When specified, it should be callable. Unpacker calls it with a list of key-value pairs after unpacking msgpack map. (See also simplejson) encoding (str) Encoding used for decoding msgpack raw. If it is None (default), msgpack raw is deserialized to Python bytes. unicode_errors (str) Used for decoding msgpack raw with encoding. (default: strict ) max_buffer_size (int) Limits size of data waiting unpacked. 0 means system s INT_MAX (default). Raises BufferFull exception when it is insufficient. You should set this parameter when unpacking data from untrusted source. max_str_len (int) Limits max length of str. (default: 2**31-1) max_bin_len (int) Limits max length of bin. (default: 2**31-1) max_array_len (int) Limits max length of array. (default: 2**31-1) max_map_len (int) Limits max length of map. (default: 2**31-1) example of streaming deserialize from file-like object: unpacker = Unpacker(file_like) for o in unpacker: process(o) example of streaming deserialize from socket: unpacker = Unpacker() while True: buf = sock.recv(1024**2) if not buf: break unpacker.feed(buf) for o in unpacker: process(o) feed(self, next_bytes) Append next_bytes to internal buffer. read_array_header(self, write_bytes=none) assuming the next object is an array, return its size n, such that the next n unpack() calls will iterate over its contents. Raises OutOfData when there are no more bytes to unpack. read_bytes(self, Py_ssize_t nbytes) Read a specified number of raw bytes from the stream 5

read_map_header(self, write_bytes=none) assuming the next object is a map, return its size n, such that the next n * 2 unpack() calls will iterate over its key-value pairs. Raises OutOfData when there are no more bytes to unpack. skip(self, write_bytes=none) Read and ignore one object, returning None If write_bytes is not None, it will be called with parts of the raw message as it is unpacked. Raises OutOfData when there are no more bytes to unpack. tell(self ) unpack(self, write_bytes=none) Unpack one object If write_bytes is not None, it will be called with parts of the raw message as it is unpacked. Raises OutOfData when there are no more bytes to unpack. class msgpack.exttype ExtType represents ext type in msgpack. 1.1 exceptions (For example, msgpack.outofdata is shortcut for msg- These exceptions are accessible via msgpack package. pack.exceptions.outofdata) exception msgpack.exceptions.bufferfull Bases: msgpack.exceptions.unpackexception exception msgpack.exceptions.extradata(unpacked, extra) Bases: msgpack.exceptions.unpackvalueerror exception msgpack.exceptions.outofdata Bases: msgpack.exceptions.unpackexception exception msgpack.exceptions.packexception Bases: Exception Deprecated. Use Exception instead to catch all exception during packing. exception msgpack.exceptions.packoverflowerror Bases: msgpack.exceptions.packvalueerror, OverflowError PackOverflowError is raised when integer value is out of range of msgpack support [-2**31, 2**32). Deprecated. Use ValueError instead. exception msgpack.exceptions.packvalueerror Bases: msgpack.exceptions.packexception, ValueError PackValueError is raised when type of input data is supported but it s value is unsupported. Deprecated. Use ValueError instead. exception msgpack.exceptions.unpackexception Bases: Exception Deprecated. Use Exception instead to catch all exception during unpacking. 6 Chapter 1. API reference

exception msgpack.exceptions.unpackvalueerror Bases: msgpack.exceptions.unpackexception, ValueError Deprecated. Use ValueError instead. 1.1. exceptions 7

8 Chapter 1. API reference

Python Module Index m msgpack, 3 msgpack.exceptions, 6 9

10 Python Module Index

Index B BufferFull, 6 bytes() (msgpack.packer method), 4 E ExtraData, 6 ExtType (class in msgpack), 6 F feed() (msgpack.unpacker method), 5 M msgpack (module), 3 msgpack.exceptions (module), 6 O OutOfData, 6 P pack() (in module msgpack), 3 pack() (msgpack.packer method), 4 pack_array_header() (msgpack.packer method), 4 pack_ext_type() (msgpack.packer method), 4 pack_map_header() (msgpack.packer method), 4 pack_map_pairs() (msgpack.packer method), 4 packb() (in module msgpack), 3 Packer (class in msgpack), 3 PackException, 6 PackOverflowError, 6 PackValueError, 6 R read_array_header() (msgpack.unpacker method), 5 read_bytes() (msgpack.unpacker method), 5 read_map_header() (msgpack.unpacker method), 5 reset() (msgpack.packer method), 4 S skip() (msgpack.unpacker method), 6 T tell() (msgpack.unpacker method), 6 U unpack() (in module msgpack), 3 unpack() (msgpack.unpacker method), 6 unpackb() (in module msgpack), 3 Unpacker (class in msgpack), 4 UnpackException, 6 UnpackValueError, 6 11