Top Description Fields Constructors Methods
org.python.core

public Class PyMemoryView

extends PySequence
implements BufferProtocol, Traverseproc
Class Inheritance
All Implemented Interfaces
org.python.core.Traverseproc, org.python.core.BufferProtocol
Annotations
@ExposedType
name:memoryview
doc:memoryview(object) Create a new memoryview object which references the given object.
base:PyObject
isBaseType:false
Imports
java.nio.ByteBuffer, org.python.core.buffer.BaseBuffer, org.python.core.util.StringUtil, org.python.expose.ExposedGet, .ExposedMethod, .ExposedNew, .ExposedType, .MethodType

Class implementing the Python memoryview type. It provides a wrapper around the Jython buffer API.

Field Summary

Modifier and TypeField 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
hashCache

Hash value cached (so we still know it after release() is called.

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
Inherited from org.python.core.PySequence:
delegator

Constructor Summary

AccessConstructor and Description
public
PyMemoryView(BufferProtocol
buffer exported by some underlying object
pybuf
)

Construct a PyMemoryView from an object bearing the BufferProtocol interface.

Method Summary

Modifier and TypeMethod and Description
public PyObject

Returns:

this object
__enter__
()

Called at the start of a context-managed suite (supporting the with clause).

public PyObject
__eq__(PyObject
the object to compare this with.
other
)

Overrides org.python.core.PySequence.__eq__.

Equivalent to the standard Python __eq__ method.

public boolean

Returns:

false
__exit__
(PyObject type, PyObject value, PyObject traceback)

Called at the end of a context-managed suite (supporting the with clause), and will release the memoryview.

public PyObject
__ge__(PyObject
the object to compare this with.
other
)

Overrides org.python.core.PySequence.__ge__.

Equivalent to the standard Python __ge__ method.

public PyObject
__gt__(PyObject
the object to compare this with.
other
)

Overrides org.python.core.PySequence.__gt__.

Equivalent to the standard Python __gt__ method.

public PyObject
__le__(PyObject
the object to compare this with.
other
)

Overrides org.python.core.PySequence.__le__.

Equivalent to the standard Python __le__ method.

public int
__len__()

Overrides org.python.core.PyObject.__len__.

Equivalent to the standard Python __len__ method.

public PyObject
__lt__(PyObject
the object to compare this with.
other
)

Overrides org.python.core.PySequence.__lt__.

Equivalent to the standard Python __lt__ method.

public PyObject
__ne__(PyObject
the object to compare this with.
other
)

Overrides org.python.core.PySequence.__ne__.

Equivalent to the standard Python __ne__ method.

public Object
__tojava__(Class<?>
the Class to convert this PyObject to.
c
)

Overrides org.python.core.PySequence.__tojava__.

Equivalent to the Jython __tojava__ method.

protected void
checkNotReleased()

Check that the memoryview is not released and raise a ValueError if it is.

private static int

Returns:

1, 0 or -1 as a>b, a==b, or a<b respectively
compare
(PyBuffer
left-hand wrapped array in the comparison
a
,
PyBuffer
right-hand wrapped object in the comparison
b
)

Comparison function between two buffers of bytes, returning 1, 0 or -1 as a>b, a==b, or a<b respectively.

public String
public synchronized PyBuffer
getBuffer(int
specifying features demanded and the navigational capabilities of the consumer
flags
)

Implements org.python.core.BufferProtocol.getBuffer.

Method by which the consumer requests the buffer from the exporter.

protected synchronized PyMemoryView

Returns:

a PyMemoryView corresponding the the given range of elements.
getslice
(int
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.python.core.PySequence.getslice.

Returns a slice of elements from this sequence as a PyMemoryView.

public int
hashCode()

Overrides org.python.core.PyObject.hashCode.

Returns a hash code value for this object.

public int
pack-priv final PyObject
pack-priv final PyObject

Returns:

Python boolean result or null if not implemented for the other type.
memoryview___eq__
(PyObject
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.
memoryview___ge__
(PyObject
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.
memoryview___gt__
(PyObject
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.
memoryview___le__
(PyObject
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.
memoryview___lt__
(PyObject
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.
memoryview___ne__
(PyObject
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 implemented
memoryview_cmp
(PyObject b)

Comparison 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 implemented
memoryview_cmpeq
(PyObject b)

Fail-fast comparison function between byte array types and any other object, for when the test is only for equality.

pack-priv static PyObject
memoryview_new(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords)

public final synchronized void
pack-priv final PyString
pack-priv final PyList
public int
ndim()

public PyObject
obj()

protected PyString

Returns:

one-character string formed from the byte at the index
pyget
(int
index of the element to get.
index
)

Implements abstract org.python.core.PySequence.pyget.

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.python.core.PySequence.pyset.

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
public synchronized void
release()

Request a release of the underlying buffer exposed by the memoryview object.

protected synchronized PyMemoryView

Returns:

never
repeat
(int
the number of times to repeat this.
count
)

Implements abstract org.python.core.PySequence.repeat.

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.python.core.PySequence.setslice.

Sets the given range of elements according to Python slice assignment semantics.

public PyObject
public PyObject
public PyObject
public PyString

Returns:

byte string of buffer contents.
tobytes
()

Implementation of Python tobytes().

public PyList

Returns:

a list of buffer contents.
tolist
()

Implementation of Python tolist().

public int
traverse(Visitproc visit, Object arg)

Implements org.python.core.Traverseproc.traverse.

Traverses all directly contained PyObjects.

private PyObject

Returns:

the PyTuple (or Py.None)
tupleOf
(int[]
the array (or null)
x
)

Make an integer array into a PyTuple of PyLong values or None if the argument is null.

Inherited from org.python.core.PySequence:
__delitem____delslice____finditem____finditem____getitem____getslice____iter____nonzero____setitem____setitem____setslice__boundToSequencecmpdeldelRangedelslicefastSequenceisMappingTypeisNumberTypeisSequenceTypeisSubTyperunsupportedopMessageseq___delitem__seq___delslice__seq___eq__seq___finditem__seq___finditem__seq___ge__seq___getitem__seq___getslice__seq___gt__seq___iter__seq___le__seq___lt__seq___ne__seq___nonzero__seq___setitem__seq___setslice__sliceLengthunsupportedopMessage

Field Detail

backingback to summary
private PyBuffer backing

The buffer exported by the object of which this is a view.

c_contiguous_docback to summary
private static final String c_contiguous_doc
cast_docback to summary
private static final String cast_doc
contiguous_docback to summary
private static final String contiguous_doc
f_contiguous_docback to summary
private static final String f_contiguous_doc
format_docback to summary
private static final String format_doc
hashCacheback to summary
private int hashCache

Hash value cached (so we still know it after release() is called.

hashCacheValidback to summary
private boolean hashCacheValid
itemsize_docback to summary
private static final String itemsize_doc
nbytes_docback to summary
private static final String nbytes_doc
ndim_docback to summary
private static final String ndim_doc
obj_docback to summary
private static final String obj_doc
readonly_docback to summary
private static final String readonly_doc
release_docback to summary
private static final String release_doc
releasedback 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.

shapeback to summary
private PyObject shape

Cache the result of getting shape here.

shape_docback to summary
private static final String shape_doc
stridesback to summary
private PyObject strides

Cache the result of getting strides here.

strides_docback to summary
private static final String strides_doc
suboffsetsback to summary
private PyObject suboffsets

Cache the result of getting suboffsets here.

suboffsets_docback to summary
private static final String suboffsets_doc
tobytes_docback to summary
private static final String tobytes_doc
tolist_docback to summary
private static final String tolist_doc
TYPEback to summary
public static final PyType TYPE

Hides org.python.core.PyObject.TYPE.

Constructor Detail

PyMemoryViewback to summary
public PyMemoryView(BufferProtocol pybuf) throws ClassCastException

Construct a PyMemoryView from an object bearing the BufferProtocol interface. If this object is already an exported buffer, the memoryview takes a new lease on it. The buffer so obtained will be writable if the underlying object permits it.

Parameters
pybuf:BufferProtocol

buffer exported by some underlying object

Exceptions
ClassCastException:
in cases where pybuf.getBuffer does so.

Method Detail

__enter__back to summary
public PyObject __enter__()

Called at the start of a context-managed suite (supporting the with clause).

Returns:PyObject

this object

__eq__back to summary
public PyObject __eq__(PyObject other)

Overrides org.python.core.PySequence.__eq__.

Doc from org.python.core.PyObject.__eq__.

Equivalent to the standard Python __eq__ method.

Parameters
other:PyObject

the object to compare this with.

Returns:PyObject

the result of the comparison.

Annotations
@Override

__exit__back to summary
public boolean __exit__(PyObject type, PyObject value, PyObject traceback)

Called at the end of a context-managed suite (supporting the with clause), and will release the memoryview.

Returns:boolean

false

__ge__back to summary
public PyObject __ge__(PyObject other)

Overrides org.python.core.PySequence.__ge__.

Doc from org.python.core.PyObject.__ge__.

Equivalent to the standard Python __ge__ method.

Parameters
other:PyObject

the object to compare this with.

Returns:PyObject

the result of the comparison.

Annotations
@Override

__gt__back to summary
public PyObject __gt__(PyObject other)

Overrides org.python.core.PySequence.__gt__.

Doc from org.python.core.PyObject.__gt__.

Equivalent to the standard Python __gt__ method.

Parameters
other:PyObject

the object to compare this with.

Returns:PyObject

the result of the comparison.

Annotations
@Override

__le__back to summary
public PyObject __le__(PyObject other)

Overrides org.python.core.PySequence.__le__.

Doc from org.python.core.PyObject.__le__.

Equivalent to the standard Python __le__ method.

Parameters
other:PyObject

the object to compare this with.

Returns:PyObject

the result of the comparison.

Annotations
@Override

__len__back to summary
public int __len__()

Overrides org.python.core.PyObject.__len__.

Doc from org.python.core.PyObject.__len__.

Equivalent to the standard Python __len__ method. Part of the mapping discipline.

Returns:int

the length of the object

Annotations
@Override

__lt__back to summary
public PyObject __lt__(PyObject other)

Overrides org.python.core.PySequence.__lt__.

Doc from org.python.core.PyObject.__lt__.

Equivalent to the standard Python __lt__ method.

Parameters
other:PyObject

the object to compare this with.

Returns:PyObject

the result of the comparison.

Annotations
@Override

__ne__back to summary
public PyObject __ne__(PyObject other)

Overrides org.python.core.PySequence.__ne__.

Doc from org.python.core.PyObject.__ne__.

Equivalent to the standard Python __ne__ method.

Parameters
other:PyObject

the object to compare this with.

Returns:PyObject

the result of the comparison.

Annotations
@Override

__tojava__back to summary
public Object __tojava__(Class<?> c)

Overrides org.python.core.PySequence.__tojava__.

Doc from org.python.core.PyObject.__tojava__.

Equivalent to the Jython __tojava__ method. Tries to coerce this object to an instance of the requested Java class. Returns the special object Py.NoConversion if this PyObject can not be converted to the desired Java class.

Parameters
c:Class<?>

the Class to convert this PyObject to.

Annotations
@Override
checkNotReleasedback 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.

compareback 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: [65,66,67]<"ABC\0", for example and [] is less than every non-empty b, while []=="".

Parameters
a:PyBuffer

left-hand wrapped array in the comparison

b:PyBuffer

right-hand wrapped object in the comparison

Returns:int

1, 0 or -1 as a>b, a==b, or a<b respectively

formatback to summary
public String format()
Annotations
@ExposedGet
doc:format A string containing the format (in struct module style) for each element in the view.
getBufferback to summary
public synchronized PyBuffer getBuffer(int flags)

Implements org.python.core.BufferProtocol.getBuffer.

Doc from org.python.core.BufferProtocol.getBuffer.

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 PyBuffer#release() on the buffer it obtained, or PyBuffer#close() using try-with-resources, since some objects alter their behaviour while buffers are exported.

The PyBuffer returned from this method is just the one on which the memoryview was first constructed. The Jython buffer API is such that sharing directly is safe (as long as the get-release discipline is observed).

Parameters
flags:int

specifying features demanded and the navigational capabilities of the consumer

Returns:PyBuffer

exported buffer

Annotations
@Override

getsliceback to summary
protected synchronized PyMemoryView getslice(int start, int stop, int step)

Implements abstract org.python.core.PySequence.getslice.

Returns a slice of elements from this sequence as a PyMemoryView.

Parameters
start:int

the position of the first element.

stop:int

one more than the position of the last element.

step:int

the step size.

Returns:PyMemoryView

a PyMemoryView corresponding the the given range of elements.

Annotations
@Override

hashCodeback to summary
public int hashCode()

Overrides org.python.core.PyObject.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override

itemsizeback to summary
public int itemsize()
Annotations
@ExposedGet
doc:itemsize The size in bytes of each element of the memoryview.
memoryview___enter__back to summary
pack-priv final PyObject memoryview___enter__()
Annotations
@ExposedMethod
names:__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.

Parameters
other:PyObject

Python object to compare with

Returns:PyObject

Python boolean result or null if not implemented for the other type.

Annotations
@ExposedMethod
type:BINARY
doc:x.__eq__(y) <==> x==y

memoryview___exit__back to summary
pack-priv final boolean memoryview___exit__(PyObject type, PyObject value, PyObject traceback)
Annotations
@ExposedMethod
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.

Parameters
other:PyObject

Python object to compare with

Returns:PyObject

Python boolean result or null if not implemented for the other type.

Annotations
@ExposedMethod
type:BINARY
doc:x.__ge__(y) <==> x>=y

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.

Parameters
other:PyObject

Python object to compare with

Returns:PyObject

Python boolean result or null if not implemented for the other type.

Annotations
@ExposedMethod
type:BINARY
doc:x.__gt__(y) <==> x>y

memoryview___hash__back to summary
pack-priv final int memoryview___hash__()
Annotations
@ExposedMethod
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.

Parameters
other:PyObject

Python object to compare with

Returns:PyObject

Python boolean result or null if not implemented for the other type.

Annotations
@ExposedMethod
type:BINARY
doc:x.__le__(y) <==> x<=y

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.

Parameters
other:PyObject

Python object to compare with

Returns:PyObject

Python boolean result or null if not implemented for the other type.

Annotations
@ExposedMethod
type:BINARY
doc:x.__lt__(y) <==> x

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.

Parameters
other:PyObject

Python object to compare with

Returns:PyObject

Python boolean result or null if not implemented for the other type.

Annotations
@ExposedMethod
type:BINARY
doc:x.__ne__(y) <==> x!=y

memoryview_cmpback 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 objects are ordered by their equivalent byte sequence values, and there is no concept of a released memoryview. In Python 3, memoryview objects are not ordered but may be tested for equality: a memoryview is always equal to itself, and distinct memoryview objects are equal if they are not released, and view equal bytes. This method supports the Python 2.7 model, and should probably not survive into Jython 3.

Returns:int

1, 0 or -1 as this>b, this==b, or this<b respectively, or -2 if the comparison is not implemented

memoryview_cmpeqback 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 __eq__ and __ne__ are based on this.

In Python 2.7, memoryview objects are ordered by their equivalent byte sequence values, and there is no concept of a released memoryview. In Python 3, memoryview objects are not ordered but may be tested for equality: a memoryview is always equal to itself, and distinct memoryview objects are equal if they are not released, and view equal bytes. This method supports a compromise between of the two and should be rationalised in Jython 3.

Returns:int

0 if this==b, or +1 or -1 if this!=b, or -2 if the comparison is not implemented

memoryview_newback to summary
pack-priv static PyObject memoryview_new(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords)
Annotations
@ExposedNew
memoryview_releaseback to summary
public final synchronized void memoryview_release()
Annotations
@ExposedMethod
doc:M.release() -> None Release the underlying buffer exposed by the memoryview object.
memoryview_tobytesback to summary
pack-priv final PyString memoryview_tobytes()
Annotations
@ExposedMethod
doc:M.tobytes() -> bytes Return the data in the buffer as a bytestring (an object of class str).
memoryview_tolistback to summary
pack-priv final PyList memoryview_tolist()
Annotations
@ExposedMethod
doc:M.tolist() -> list Return the data in the buffer as a list of elements.
ndimback to summary
public int ndim()
Annotations
@ExposedGet
doc:ndim An integer indicating how many dimensions of a multi-dimensional array the memory represents.
objback to summary
public PyObject obj()
pygetback to summary
protected PyString pyget(int index)

Implements abstract org.python.core.PySequence.pyget.

Gets the indexed element of the memoryview as a one byte string. This is an extension point called by PySequence in its implementation of __getitem__. It is guaranteed by PySequence that the index is within the bounds of the memoryview.

Parameters
index:int

index of the element to get.

Returns:PyString

one-character string formed from the byte at the index

Annotations
@Override

pysetback to summary
public synchronized void pyset(int index, PyObject value) throws PyException

Overrides org.python.core.PySequence.pyset.

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 __setitem__ It is guaranteed by PySequence that the index is within the bounds of the memoryview. Any other clients calling pyset(int, PyObject) must make the same guarantee.

Parameters
index:int

index of the element to set.

value:PyObject

to set this element to, regarded as a buffer of length one unit.

Annotations
@Override
Exceptions
PyException:
  • AttributeError if value cannot be converted to an integer
  • ValueError if value<0 or value>255
readonlyback to summary
public boolean readonly()
Annotations
@ExposedGet
doc:readonly A bool indicating whether the memory is read only.
refersDirectlyToback to summary
public boolean refersDirectlyTo(PyObject ob)

Implements org.python.core.Traverseproc.refersDirectlyTo.

Doc from org.python.core.Traverseproc.refersDirectlyTo.

Optional operation. Should only be implemented if it is more efficient than calling traverse(Visitproc, Object) with a visitproc that just watches out for ob. Must return false if ob is null.

Annotations
@Override
releaseback to summary
public synchronized void release()

Request a release of the underlying buffer exposed by the memoryview object. Many objects take special actions when a view is held on them (for example, a bytearray would temporarily forbid resizing); therefore, calling release() is handy to remove these restrictions (and free any dangling resources) as soon as possible.

After this method has been called, any further operation on the view raises a ValueError (except release() itself which can be called multiple times with the same effect as just one call).

This becomes an exposed method in CPython from 3.2. The Jython implementation of memoryview follows the Python 3.3 design internally and therefore safely anticipates Python 3 in exposing memoryview.release along with the related context-management behaviour.

repeatback to summary
protected synchronized PyMemoryView repeat(int count) throws PyException

Implements abstract org.python.core.PySequence.repeat.

memoryview*int is not implemented in Python, so this should never be called. We still have to override it to satisfy PySequence.

Parameters
count:int

the number of times to repeat this.

Returns:PyMemoryView

never

Annotations
@Override
Exceptions
PyException:
NotImplemented always

setsliceback to summary
protected synchronized void setslice(int start, int stop, int step, PyObject value)

Overrides org.python.core.PySequence.setslice.

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.
Parameters
start:int

the position of the first element.

stop:int

one more than the position of the last element.

step:int

the step size.

value:PyObject

an object consistent with the slice assignment

Annotations
@Override
shapeback to summary
public PyObject shape()
Annotations
@ExposedGet
doc:shape A tuple of ndim integers giving the shape of the memory as an N-dimensional array.
stridesback to summary
public PyObject strides()
Annotations
@ExposedGet
doc:strides A tuple of ndim integers giving the size in bytes to access each element for each dimension of the array.
suboffsetsback to summary
public PyObject suboffsets()
Annotations
@ExposedGet
doc:suboffsets A tuple of ndim integers used internally for PIL-style arrays or None.
tobytesback to summary
public PyString tobytes()

Implementation of Python tobytes(). Return the data in the buffer as a byte string (an object of class str).

Returns:PyString

byte string of buffer contents.

tolistback to summary
public PyList tolist()

Implementation of Python tolist(). Return the data in the buffer as a list where the elements are an appropriate type (int in the case of a byte-oriented buffer, which is the only case presently supported).

Returns:PyList

a list of buffer contents.

traverseback to summary
public int traverse(Visitproc visit, Object arg)

Implements org.python.core.Traverseproc.traverse.

Doc from org.python.core.Traverseproc.traverse.

Traverses all directly contained PyObjects. Like in CPython, arg must be passed unmodified to visit as its second parameter. If Visitproc#visit(PyObject, Object) returns nonzero, this return value must be returned immediately by traverse. Visitproc#visit(PyObject, Object) must not be called with a null PyObject-argument.

Annotations
@Override
tupleOfback to summary
private PyObject tupleOf(int[] x)

Make an integer array into a PyTuple of PyLong values or None if the argument is null.

Parameters
x:int[]

the array (or null)

Returns:PyObject

the PyTuple (or Py.None)