buffer type. buffer is being superseded in
Python 2.7 by memoryview, and is provided here to support legacy Python code. Use
memoryview if you can.
buffer and memoryview both wrap the same Jython buffer API:
that designed for memoryview. In CPython, a new C API (which Jython's resembles) was
introduced with memoryview. Because of this, buffer and
memoryview may be supplied as arguments in the same places, and will accept as
arguments the same (one-dimensional byte-array) types. Their behaviour differs as detailed in the
documentation.
| Modifier and Type | Field and Description |
|---|---|
| private final BufferProtocol | object
The underlying object on which the buffer was created. |
| private final int | offset
The offset (in bytes) into the offered object at which the buffer starts. |
| private static String[] | paramNames
Names of arguments in the constructor (for ArgParser). |
| private final int | size
Number of bytes to include in the buffer (or -1 for all available). |
| private static final String | |
| private static final String | |
| public static final PyType |
| Access | Constructor and Description |
|---|---|
| public | Py2kBuffer(BufferProtocol
the object on which this is to be a buffer. object, int into the array exposed by the object (0 for start). offset, int of the slice or -1 for all of the object. size)Construct a Py2kBuffer from an object supporting the |
| Modifier and Type | Method and Description |
|---|---|
| public PyObject | __add__(PyObject
the object to perform this binary operation with (the right-hand operand). other)Overrides org. Equivalent to the standard Python __add__ method. |
| public int | __len__()
Overrides org. Equivalent to the standard Python __len__ method. |
| public PyObject | __mul__(PyObject
the object to perform this binary operation with (the right-hand operand). o)Overrides org. Equivalent to the standard Python __mul__ method. |
| public PyString | __repr__()
Overrides org. Equivalent to the standard Python |
| public PyObject | __rmul__(PyObject
the object to perform this binary operation with (the left-hand operand). o)Overrides org. Equivalent to the standard Python __rmul__ method. |
| public PyString | __str__()
Overrides org. Equivalent to the standard Python __str__ method. |
| private static BufferProtocol | asBufferableOrNull(PyObject
the object to access. obj)Return a |
| pack-priv final PyObject | |
| pack-priv final PyObject | |
| pack-priv final PyString | |
| pack-priv final PyObject | |
| pack-priv final PyString | |
| private int | Returns: 1, 0 or -1 as this>b, this==b, or this<b respectively, or -2 if the comparison is not implementedComparison function between this |
| private int | Returns: 0 if this==b, or +1 or -1 if this!=b, or -2 if the comparison is not implementedFail-fast comparison function between byte array types and any other object, for when the test is only for equality. |
| pack-priv static PyObject | |
| private static int | |
| private PyBuffer | |
| public PyBuffer | getBuffer(int
specifying features demanded and the navigational capabilities of the consumer flags)Implements org. Method by which the consumer requests the buffer from the exporter. |
| protected synchronized PyString | Returns: a PyString corresponding the the given range of elements.the position of the first element. start, int one more than the position of the last element. stop, int the step size. step)Implements abstract org. Returns a slice of elements from this sequence as a PyString. |
| protected PyString | Returns: one-character string formed from the byte at the indexindex of the element to get. index)Implements abstract org. Gets the indexed element of the |
| public synchronized void | pyset(int
index of the element to set. index, PyObject to set this element to, regarded as a buffer of length one unit. value)Overrides org. Sets the indexed element of the |
| protected synchronized PyString | Returns: a PyString repeating this buffer (as astr) that many timesthe number of times to repeat this. count)Implements abstract org.
|
| protected synchronized void | setslice(int
the position of the first element. start, int one more than the position of the last element. stop, int the step size. step, PyObject an object consistent with the slice assignment value)Overrides org. Sets the given range of elements according to Python slice assignment semantics. |
| public String | toString()
Overrides org. Returns a string representation of the object. |
| object | back to summary |
|---|---|
| private final BufferProtocol object The underlying object on which the buffer was created. | |
| offset | back to summary |
|---|---|
| private final int offset The offset (in bytes) into the offered object at which the buffer starts. | |
| paramNames | back to summary |
|---|---|
| private static String[] paramNames Names of arguments in the constructor (for ArgParser). | |
| size | back to summary |
|---|---|
| private final int size Number of bytes to include in the buffer (or -1 for all available). | |
| tobytes_doc | back to summary |
|---|---|
| private static final String tobytes_doc | |
| tolist_doc | back to summary |
|---|---|
| private static final String tolist_doc | |
| TYPE | back to summary |
|---|---|
| public static final PyType TYPE | |
| Py2kBuffer | back to summary |
|---|---|
| public Py2kBuffer(BufferProtocol object, int offset, int size) Construct a Py2kBuffer from an object supporting the
| |
| __add__ | back to summary |
|---|---|
| public PyObject __add__(PyObject other) Overrides org. Doc from org. Equivalent to the standard Python __add__ method. A | |
| __len__ | back to summary |
|---|---|
| public int __len__() Overrides org. Doc from org. Equivalent to the standard Python __len__ method. Part of the mapping discipline.
| |
| __mul__ | back to summary |
|---|---|
| public PyObject __mul__(PyObject o) Overrides org. Doc from org. Equivalent to the standard Python __mul__ method. On a | |
| __repr__ | back to summary |
|---|---|
| public PyString __repr__() Overrides org. Doc from org. Equivalent to the standard Python
| |
| __rmul__ | back to summary |
|---|---|
| public PyObject __rmul__(PyObject o) Overrides org. Doc from org. Equivalent to the standard Python __rmul__ method. On a | |
| __str__ | back to summary |
|---|---|
| public PyString __str__() Overrides org. Doc from org. Equivalent to the standard Python __str__ method. The default implementation (in
| |
| asBufferableOrNull | back to summary |
|---|---|
| private static BufferProtocol asBufferableOrNull(PyObject obj) Return a
| |
| buffer___add__ | back to summary |
|---|---|
pack-priv final PyObject buffer___add__(PyObject other)
| |
| buffer___mul__ | back to summary |
|---|---|
pack-priv final PyObject buffer___mul__(PyObject o)
| |
| buffer___repr__ | back to summary |
|---|---|
pack-priv final PyString buffer___repr__()
| |
| buffer___rmul__ | back to summary |
|---|---|
pack-priv final PyObject buffer___rmul__(PyObject o)
| |
| buffer___str__ | back to summary |
|---|---|
pack-priv final PyString buffer___str__()
| |
| buffer_cmp | back to summary |
|---|---|
| private int buffer_cmp(PyObject b) Comparison function between this
| |
| buffer_cmpeq | back to summary |
|---|---|
| private int buffer_cmpeq(PyObject b) Fail-fast comparison function between byte array types and any other object, for when the
test is only for equality. The inequality comparison operators
| |
| buffer_new | back to summary |
|---|---|
pack-priv static PyObject buffer_new(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords)
| |
| compare | back to summary |
|---|---|
| private static int compare(PyBuffer a, PyBuffer b) Comparison function between two
1, 0 or -1 as a>b, a==b, or a<b respectively | |
| getBuffer | back to summary |
|---|---|
| private PyBuffer getBuffer() Every action on the
| |
| getBuffer | back to summary |
|---|---|
| public PyBuffer getBuffer(int flags) Implements org. Doc from org. Method by which the consumer requests the buffer from the exporter. The consumer provides
information on its ability to understand buffer navigation. Each consumer requesting a buffer
in this way, when it has finished using it, should make a corresponding call to
The | |
| getslice | back to summary |
|---|---|
| protected synchronized PyString getslice(int start, int stop, int step) Implements abstract org. Returns a slice of elements from this sequence as a PyString.
a PyString corresponding the the given range of elements. | |
| pyget | back to summary |
|---|---|
| protected PyString pyget(int index) Implements abstract org. Gets the indexed element of the | |
| pyset | back to summary |
|---|---|
| public synchronized void pyset(int index, PyObject value) throws PyException Overrides org. Sets the indexed element of the
| |
| repeat | back to summary |
|---|---|
| protected synchronized PyString repeat(int count) Implements abstract org.
| |
| setslice | back to summary |
|---|---|
| protected synchronized void setslice(int start, int stop, int step, PyObject value) Overrides org. Sets the given range of elements according to Python slice assignment semantics. If the step size is one, it is a simple slice and the operation is equivalent to replacing that slice, with the value, accessing the value via the buffer protocol. a = bytearray(b'abcdefghijklmnopqrst') m = buffer(a) m[2:7] = "ABCDE"Results in a=bytearray(b'abABCDEhijklmnopqrst').
If the step size is one, but stop-start does not match the length of the right-hand-side a ValueError is thrown. If the step size is not one, and start!=stop, the slice defines a certain number of elements to be replaced. This function is not available in Python 2.7 (but it is in Python 3.3).
a = bytearray(b'abcdefghijklmnopqrst') a[2:12:2] = iter( [65, 66, 67, long(68), "E"] )Results in a=bytearray(b'abAdBfChDjElmnopqrst') in Python 3.3.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |