msgpack/msgpack-python — pull request #47 by stephan-hof (2013-02-17 14:01:06+00:00)
Title: Give python access to the internal buffer of Packer

Hi, this pull request is a slightly performance improvement to the packer.
This patch adds a API to access the internal buffer of the packer by converting it to a buffer/memoryview object.

This buffer/memoryview can be passed to the typical functions, like
socket.send, socket.sendall, file.write, ....
These functions access then directly the char* buffer from the Packer.
This approach avoids the memory allocation and memory copy done in PyBytes_FromStringAndSize also known as 'Zero-copy'

Important note: used incorrectly it possible to produce segfaults.
For example this code will segfault
```python
from msgpack import Packer
Packer().pack(range(100), ret_as_buff=1)[100]
```
because the packer is deallocated but the returned buffer points still to the internal memory.