memoryview type. It provides a wrapper around the
Jython buffer API.
| Modifier and Type | Field and Description |
|---|---|
| private PyBuffer | backing
The buffer exported by the object of which this is a view. |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private int | |
| private boolean | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private boolean | released
A memoryview in the released state forbids most Python API actions. |
| private PyObject | shape
Cache the result of getting shape here. |
| private static final String | |
| private PyObject | strides
Cache the result of getting strides here. |
| private static final String | |
| private PyObject | suboffsets
Cache the result of getting suboffsets here. |
| private static final String | |
| private static final String | |
| private static final String | |
| public static final PyType |
| Access | Constructor and Description |
|---|---|
| public | PyMemoryView(BufferProtocol
buffer exported by some underlying object pybuf)Construct a |
| Modifier and Type | Method and Description |
|---|---|
| public PyObject | Returns: this objectCalled at the start of a context-managed suite (supporting the |
| public PyObject | __eq__(PyObject
the object to compare this with. other)Overrides org. Equivalent to the standard Python __eq__ method. |
| public boolean | |
| public PyObject | __ge__(PyObject
the object to compare this with. other)Overrides org. Equivalent to the standard Python __ge__ method. |
| public PyObject | __gt__(PyObject
the object to compare this with. other)Overrides org. Equivalent to the standard Python __gt__ method. |
| public PyObject | __le__(PyObject
the object to compare this with. other)Overrides org. Equivalent to the standard Python __le__ method. |
| public int | __len__()
Overrides org. Equivalent to the standard Python __len__ method. |
| public PyObject | __lt__(PyObject
the object to compare this with. other)Overrides org. Equivalent to the standard Python __lt__ method. |
| public PyObject | __ne__(PyObject
the object to compare this with. other)Overrides org. Equivalent to the standard Python __ne__ method. |
| public Object | __tojava__(Class<?>
the Class to convert this c)PyObject to.Overrides org. Equivalent to the Jython __tojava__ method. |
| protected void | |
| private static int | |
| public String | |
| public synchronized 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 PyMemoryView | Returns: a PyMemoryView 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 PyMemoryView. |
| public int | |
| public int | |
| pack-priv final PyObject | |
| pack-priv final PyObject | Returns: Python boolean result or null if not implemented for the other type.Python object to compare with other)Implementation of __eq__ (equality) operator. |
| pack-priv final boolean | |
| pack-priv final PyObject | Returns: Python boolean result or null if not implemented for the other type.Python object to compare with other)Implementation of __ge__ (greater than or equal to) operator. |
| pack-priv final PyObject | Returns: Python boolean result or null if not implemented for the other type.Python object to compare with other)Implementation of __gt__ (greater than) operator. |
| pack-priv final int | |
| pack-priv final PyObject | Returns: Python boolean result or null if not implemented for the other type.Python object to compare with other)Implementation of __le__ (less than or equal to) operator. |
| pack-priv final PyObject | Returns: Python boolean result or null if not implemented for the other type.Python object to compare with other)Implementation of __lt__ (less than) operator. |
| pack-priv final PyObject | Returns: Python boolean result or null if not implemented for the other type.Python object to compare with other)Implementation of __ne__ (not equals) operator. |
| 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 memoryview and any other object. |
| 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 | |
| public final synchronized void | |
| pack-priv final PyString | |
| pack-priv final PyList | |
| public int | |
| public PyObject | |
| 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 memoryview as a one byte string. |
| 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 memoryview to the given value, treating the operation as assignment to a slice of length one. |
| public boolean | |
| public boolean | refersDirectlyTo(PyObject ob)
Implements org. Optional operation. |
| public synchronized void | |
| protected synchronized PyMemoryView | Returns: neverthe number of times to repeat this. count)Implements abstract org. memoryview*int is not implemented in Python, so this should never be called. |
| 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 PyObject | |
| public PyObject | |
| public PyObject | |
| public PyString | |
| public PyList | |
| public int | traverse(Visitproc visit, Object arg)
Implements org. Traverses all directly contained |
| private PyObject | Returns: the PyTuple (or Py.None)the array (or null) x)Make an integer array into a PyTuple of PyLong values or None if the argument is null. |
| backing | back to summary |
|---|---|
| private PyBuffer backing The buffer exported by the object of which this is a view. | |
| c_contiguous_doc | back to summary |
|---|---|
| private static final String c_contiguous_doc | |
| cast_doc | back to summary |
|---|---|
| private static final String cast_doc | |
| contiguous_doc | back to summary |
|---|---|
| private static final String contiguous_doc | |
| f_contiguous_doc | back to summary |
|---|---|
| private static final String f_contiguous_doc | |
| format_doc | back to summary |
|---|---|
| private static final String format_doc | |
| hashCache | back to summary |
|---|---|
| private int hashCache Hash value cached (so we still know it after | |
| hashCacheValid | back to summary |
|---|---|
| private boolean hashCacheValid | |
| itemsize_doc | back to summary |
|---|---|
| private static final String itemsize_doc | |
| nbytes_doc | back to summary |
|---|---|
| private static final String nbytes_doc | |
| ndim_doc | back to summary |
|---|---|
| private static final String ndim_doc | |
| obj_doc | back to summary |
|---|---|
| private static final String obj_doc | |
| readonly_doc | back to summary |
|---|---|
| private static final String readonly_doc | |
| release_doc | back to summary |
|---|---|
| private static final String release_doc | |
| released | back to summary |
|---|---|
| private boolean released A memoryview in the released state forbids most Python API actions. If the underlying PyBuffer is shared, the memoryview may be released while the underlying PyBuffer is not "finally" released. | |
| shape | back to summary |
|---|---|
| private PyObject shape Cache the result of getting shape here. | |
| shape_doc | back to summary |
|---|---|
| private static final String shape_doc | |
| strides | back to summary |
|---|---|
| private PyObject strides Cache the result of getting strides here. | |
| strides_doc | back to summary |
|---|---|
| private static final String strides_doc | |
| suboffsets | back to summary |
|---|---|
| private PyObject suboffsets Cache the result of getting suboffsets here. | |
| suboffsets_doc | back to summary |
|---|---|
| private static final String suboffsets_doc | |
| 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 | |
| PyMemoryView | back to summary |
|---|---|
| public PyMemoryView(BufferProtocol pybuf) throws ClassCastException Construct a
| |
| __enter__ | back to summary |
|---|---|
| public PyObject __enter__() Called at the start of a context-managed suite (supporting the
| |
| __eq__ | back to summary |
|---|---|
| public PyObject __eq__(PyObject other) Overrides org. Doc from org. Equivalent to the standard Python __eq__ method. | |
| __exit__ | back to summary |
|---|---|
| public boolean __exit__(PyObject type, PyObject value, PyObject traceback) Called at the end of a context-managed suite (supporting the
| |
| __ge__ | back to summary |
|---|---|
| public PyObject __ge__(PyObject other) Overrides org. Doc from org. Equivalent to the standard Python __ge__ method. | |
| __gt__ | back to summary |
|---|---|
| public PyObject __gt__(PyObject other) Overrides org. Doc from org. Equivalent to the standard Python __gt__ method. | |
| __le__ | back to summary |
|---|---|
| public PyObject __le__(PyObject other) Overrides org. Doc from org. Equivalent to the standard Python __le__ method. | |
| __len__ | back to summary |
|---|---|
| public int __len__() Overrides org. Doc from org. Equivalent to the standard Python __len__ method. Part of the mapping discipline.
| |
| __lt__ | back to summary |
|---|---|
| public PyObject __lt__(PyObject other) Overrides org. Doc from org. Equivalent to the standard Python __lt__ method. | |
| __ne__ | back to summary |
|---|---|
| public PyObject __ne__(PyObject other) Overrides org. Doc from org. Equivalent to the standard Python __ne__ method. | |
| __tojava__ | back to summary |
|---|---|
| public Object __tojava__(Class<?> c) Overrides org. Doc from org. Equivalent to the Jython __tojava__ method. Tries to coerce this object to an instance of the
requested Java class. Returns the special object | |
| checkNotReleased | back to summary |
|---|---|
| protected void checkNotReleased() Check that the memoryview is not released and raise a ValueError if it is. Almost every operation must call this before it starts work. | |
| compare | back to summary |
|---|---|
| private static int compare(PyBuffer a, PyBuffer b) Comparison function between two buffers of bytes, returning 1, 0 or -1 as a>b, a==b, or
a<b respectively. The comparison is by value, using Python unsigned byte conventions,
left-to-right (low to high index). Zero bytes are significant, even at the end of the array:
1, 0 or -1 as a>b, a==b, or a<b respectively | |
| format | back to summary |
|---|---|
public String format()
| |
| getBuffer | back to summary |
|---|---|
| public synchronized 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 PyMemoryView getslice(int start, int stop, int step) Implements abstract org. Returns a slice of elements from this sequence as a PyMemoryView.
a PyMemoryView corresponding the the given range of elements. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides org. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| itemsize | back to summary |
|---|---|
public int itemsize()
| |
| memoryview___enter__ | back to summary |
|---|---|
pack-priv final PyObject memoryview___enter__()
| |
| memoryview___eq__ | back to summary |
|---|---|
| pack-priv final PyObject memoryview___eq__(PyObject other) Implementation of __eq__ (equality) operator. Comparison with an invalid type returns null.
| |
| memoryview___exit__ | back to summary |
|---|---|
pack-priv final boolean memoryview___exit__(PyObject type, PyObject value, PyObject traceback)
| |
| memoryview___ge__ | back to summary |
|---|---|
| pack-priv final PyObject memoryview___ge__(PyObject other) Implementation of __ge__ (greater than or equal to) operator. Comparison with an invalid type returns null.
| |
| memoryview___gt__ | back to summary |
|---|---|
| pack-priv final PyObject memoryview___gt__(PyObject other) Implementation of __gt__ (greater than) operator. Comparison with an invalid type returns null.
| |
| memoryview___hash__ | back to summary |
|---|---|
pack-priv final int memoryview___hash__()
| |
| memoryview___le__ | back to summary |
|---|---|
| pack-priv final PyObject memoryview___le__(PyObject other) Implementation of __le__ (less than or equal to) operator. Comparison with an invalid type returns null.
| |
| memoryview___lt__ | back to summary |
|---|---|
| pack-priv final PyObject memoryview___lt__(PyObject other) Implementation of __lt__ (less than) operator. Comparison with an invalid type returns null.
| |
| memoryview___ne__ | back to summary |
|---|---|
| pack-priv final PyObject memoryview___ne__(PyObject other) Implementation of __ne__ (not equals) operator. Comparison with an invalid type returns null.
| |
| memoryview_cmp | back to summary |
|---|---|
| private int memoryview_cmp(PyObject b) Comparison function between this memoryview and any other object. The inequality comparison operators are based on this.
In Python 2.7,
| |
| memoryview_cmpeq | back to summary |
|---|---|
| private int memoryview_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
In Python 2.7,
| |
| memoryview_new | back to summary |
|---|---|
pack-priv static PyObject memoryview_new(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords)
| |
| memoryview_release | back to summary |
|---|---|
public final synchronized void memoryview_release()
| |
| memoryview_tobytes | back to summary |
|---|---|
pack-priv final PyString memoryview_tobytes()
| |
| memoryview_tolist | back to summary |
|---|---|
pack-priv final PyList memoryview_tolist()
| |
| ndim | back to summary |
|---|---|
public int ndim()
| |
| obj | back to summary |
|---|---|
| public PyObject obj() | |
| pyget | back to summary |
|---|---|
| protected PyString pyget(int index) Implements abstract org. Gets the indexed element of the memoryview as a one byte string. This is an extension point
called by PySequence in its implementation of | |
| pyset | back to summary |
|---|---|
| public synchronized void pyset(int index, PyObject value) throws PyException Overrides org. Sets the indexed element of the memoryview to the given value, treating the operation as
assignment to a slice of length one. This is different from the same operation on a byte
array, where the assigned value must be an int: here it must have the buffer API and length
one. This is an extension point called by PySequence in its implementation of
| |
| readonly | back to summary |
|---|---|
public boolean readonly()
| |
| refersDirectlyTo | back to summary |
|---|---|
| public boolean refersDirectlyTo(PyObject ob) Implements org. Doc from org. Optional operation.
Should only be implemented if it is more efficient
than calling
| |
| release | back to summary |
|---|---|
| public synchronized void release() Request a release of the underlying buffer exposed by the
After this method has been called, any further operation on the view raises a
This becomes an exposed method in CPython from 3.2. The Jython implementation of
| |
| repeat | back to summary |
|---|---|
| protected synchronized PyMemoryView repeat(int count) throws PyException Implements abstract org. memoryview*int is not implemented in Python, so this should never be called. We still have to override it to satisfy PySequence.
| |
| 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 = memoryview(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.
| |
| shape | back to summary |
|---|---|
public PyObject shape()
| |
| strides | back to summary |
|---|---|
public PyObject strides()
| |
| suboffsets | back to summary |
|---|---|
public PyObject suboffsets()
| |
| tobytes | back to summary |
|---|---|
| public PyString tobytes() Implementation of Python
| |
| tolist | back to summary |
|---|---|
| public PyList tolist() Implementation of Python
| |
| traverse | back to summary |
|---|---|
| public int traverse(Visitproc visit, Object arg) Implements org. Doc from org. Traverses all directly contained
| |
| tupleOf | back to summary |
|---|---|
| private PyObject tupleOf(int[] x) Make an integer array into a PyTuple of PyLong values or None if the argument is null.
| |