SciPy

numpy.getbuffer

numpy.getbuffer(obj[, offset[, size]])

Create a buffer object from the given object referencing a slice of length size starting at offset.

Default is the entire buffer. A read-write buffer is attempted followed by a read-only buffer.

Parameters :

obj : object

offset : int, optional

size : int, optional

Returns :

buffer_obj : buffer

Examples

>>> buf = np.getbuffer(np.ones(5), 1, 3)
>>> len(buf)
3
>>> buf[0]
'\x00'
>>> buf
<read-write buffer for 0x8af1e70, size 3, offset 1 at 0x8ba4ec0>

Previous topic

numpy.getbufsize

Next topic

numpy.newbuffer