Merge branch 'master' of github.com:msgpack/msgpack-python
This commit is contained in:
		
							
								
								
									
										22
									
								
								README.rst
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								README.rst
									
									
									
									
									
								
							@@ -8,6 +8,10 @@ MessagePack for Python
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
.. image:: https://secure.travis-ci.org/msgpack/msgpack-python.png
 | 
					.. image:: https://secure.travis-ci.org/msgpack/msgpack-python.png
 | 
				
			||||||
   :target: https://travis-ci.org/#!/msgpack/msgpack-python
 | 
					   :target: https://travis-ci.org/#!/msgpack/msgpack-python
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
					.. image:: https://pypip.in/version/msgpack-python/badge.svg
 | 
				
			||||||
 | 
					    :target: https://pypi.python.org/pypi/msgpack-python/
 | 
				
			||||||
 | 
					    :alt: Latest Version
 | 
				
			||||||
 | 
					
 | 
				
			||||||
What's this
 | 
					What's this
 | 
				
			||||||
------------
 | 
					------------
 | 
				
			||||||
@@ -52,6 +56,8 @@ It is non-string binary like Python 3's ``bytes``.
 | 
				
			|||||||
To use *bin* type for packing ``bytes``, pass ``use_bin_type=True`` to
 | 
					To use *bin* type for packing ``bytes``, pass ``use_bin_type=True`` to
 | 
				
			||||||
packer argument.
 | 
					packer argument.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.. code-block:: pycon
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    >>> import msgpack
 | 
					    >>> import msgpack
 | 
				
			||||||
    >>> packed = msgpack.packb([b'spam', u'egg'], use_bin_type=True)
 | 
					    >>> packed = msgpack.packb([b'spam', u'egg'], use_bin_type=True)
 | 
				
			||||||
    >>> msgpack.unpackb(packed, encoding='utf-8')
 | 
					    >>> msgpack.unpackb(packed, encoding='utf-8')
 | 
				
			||||||
@@ -62,6 +68,8 @@ binary can be unpacked by unpackers supporting msgpack-2.0.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
To use *ext* type, pass ``msgpack.ExtType`` object to packer.
 | 
					To use *ext* type, pass ``msgpack.ExtType`` object to packer.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.. code-block:: pycon
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    >>> import msgpack
 | 
					    >>> import msgpack
 | 
				
			||||||
    >>> packed = msgpack.packb(msgpack.ExtType(42, b'xyzzy'))
 | 
					    >>> packed = msgpack.packb(msgpack.ExtType(42, b'xyzzy'))
 | 
				
			||||||
    >>> msgpack.unpackb(packed)
 | 
					    >>> msgpack.unpackb(packed)
 | 
				
			||||||
@@ -95,7 +103,7 @@ msgpack provides ``dumps`` and ``loads`` as alias for compatibility with
 | 
				
			|||||||
``pack`` and ``dump`` packs to file-like object.
 | 
					``pack`` and ``dump`` packs to file-like object.
 | 
				
			||||||
``unpack`` and ``load`` unpacks from file-like object.
 | 
					``unpack`` and ``load`` unpacks from file-like object.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
::
 | 
					.. code-block:: pycon
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   >>> import msgpack
 | 
					   >>> import msgpack
 | 
				
			||||||
   >>> msgpack.packb([1, 2, 3])
 | 
					   >>> msgpack.packb([1, 2, 3])
 | 
				
			||||||
@@ -103,7 +111,9 @@ msgpack provides ``dumps`` and ``loads`` as alias for compatibility with
 | 
				
			|||||||
   >>> msgpack.unpackb(_)
 | 
					   >>> msgpack.unpackb(_)
 | 
				
			||||||
   [1, 2, 3]
 | 
					   [1, 2, 3]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
``unpack`` unpacks msgpack's array to Python's list, but can unpack to tuple::
 | 
					``unpack`` unpacks msgpack's array to Python's list, but can unpack to tuple:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.. code-block:: pycon
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   >>> msgpack.unpackb(b'\x93\x01\x02\x03', use_list=False)
 | 
					   >>> msgpack.unpackb(b'\x93\x01\x02\x03', use_list=False)
 | 
				
			||||||
   (1, 2, 3)
 | 
					   (1, 2, 3)
 | 
				
			||||||
@@ -119,7 +129,7 @@ Streaming unpacking
 | 
				
			|||||||
``Unpacker`` is a "streaming unpacker". It unpacks multiple objects from one
 | 
					``Unpacker`` is a "streaming unpacker". It unpacks multiple objects from one
 | 
				
			||||||
stream (or from bytes provided through its ``feed`` method).
 | 
					stream (or from bytes provided through its ``feed`` method).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
::
 | 
					.. code-block:: python
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   import msgpack
 | 
					   import msgpack
 | 
				
			||||||
   from io import BytesIO
 | 
					   from io import BytesIO
 | 
				
			||||||
@@ -141,7 +151,7 @@ Packing/unpacking of custom data type
 | 
				
			|||||||
It is also possible to pack/unpack custom data types. Here is an example for
 | 
					It is also possible to pack/unpack custom data types. Here is an example for
 | 
				
			||||||
``datetime.datetime``.
 | 
					``datetime.datetime``.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
::
 | 
					.. code-block:: python
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    import datetime
 | 
					    import datetime
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -175,6 +185,8 @@ Extended types
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
It is also possible to pack/unpack custom data types using the msgpack 2.0 feature.
 | 
					It is also possible to pack/unpack custom data types using the msgpack 2.0 feature.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.. code-block:: pycon
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    >>> import msgpack
 | 
					    >>> import msgpack
 | 
				
			||||||
    >>> import array
 | 
					    >>> import array
 | 
				
			||||||
    >>> def default(obj):
 | 
					    >>> def default(obj):
 | 
				
			||||||
@@ -209,7 +221,7 @@ in a map, can be unpacked or skipped individually.
 | 
				
			|||||||
Each of these methods may optionally write the packed data it reads to a
 | 
					Each of these methods may optionally write the packed data it reads to a
 | 
				
			||||||
callback function:
 | 
					callback function:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
::
 | 
					.. code-block:: python
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    from io import BytesIO
 | 
					    from io import BytesIO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user