Top Description Fields Constructors Methods
org.python.core

public Class PyByteArray

extends BaseBytes
implements BufferProtocol
Class Inheritance
All Implemented Interfaces
org.python.core.BufferProtocol
Known Direct Subclasses
org.python.core.PyByteArrayDerived
Annotations
@Untraversable
@ExposedType
name:bytearray
base:PyObject
doc:bytearray(iterable_of_ints) -> bytearray. bytearray(string, encoding[, errors]) -> bytearray. bytearray(bytes_or_bytearray) -> mutable copy of bytes_or_bytearray. bytearray(memory_view) -> bytearray. Construct an mutable bytearray object from: - an iterable yielding integers in range(256) - a text string encoded using the specified encoding - a bytes or a bytearray object - any object implementing the buffer API. bytearray(int) -> bytearray. Construct a zero-initialized bytearray of the given length.
Imports
java.lang.ref.WeakReference, java.util.Arrays, org.python.core.buffer.BaseBuffer, .SimpleWritableBuffer, org.python.expose.ExposedClassMethod, .ExposedMethod, .ExposedNew, .ExposedType, .MethodType

Implementation of Python bytearray with a Java API that includes equivalents to most of the Python API. These Python equivalents accept a PyObject as argument, where you might have expected a byte[] or PyByteArray, in order to accommodate the full range of types accepted by the Python equivalent: usually, any PyObject that implements BufferProtocol, providing a one-dimensional array of bytes, is an acceptable argument. In the documentation, the reader will often see the terms "byte array" or "object viewable as bytes" instead of bytearray when this broader scope is intended. This may relate to parameters, or to the target object itself (in text that applies equally to base or sibling classes).

Field Summary

Modifier and TypeField and Description
private WeakReference<BaseBuffer>
export

Hold weakly a reference to a PyBuffer export not yet released, used to prevent untimely resizing.

public static final PyType
TYPE

Hides org.python.core.PyObject.TYPE.

The PyType of bytearray.
Inherited from org.python.core.BaseBytes:
emptyStoragelistDelegateoffsetsizestorage

Constructor Summary

AccessConstructor and Description
public
PyByteArray(PyType
explicit Jython type
type
)

Constructs a zero-length Python bytearray of explicitly-specified sub-type

public
PyByteArray()

Constructs a zero-length Python bytearray.

public
PyByteArray(int
of bytearray
size
)

Constructs zero-filled Python bytearray of specified size.

public
PyByteArray(int[]
source of the bytes (and size)
value
)

Constructs a bytearray by copying values from int[].

public
PyByteArray(BaseBytes
source of the bytes (and size)
value
)

Constructs a new array filled exactly by a copy of the contents of the source, which is a bytearray (or bytes).

pack-priv
PyByteArray(PyBuffer
source of the bytes (and size)
value
)

Constructs a new array filled exactly by a copy of the contents of the source, which is a byte-oriented PyBuffer.

public
PyByteArray(BufferProtocol
source of the bytes (and size)
value
)

Constructs a new array filled exactly by a copy of the contents of the source, which is an object supporting the Jython version of the PEP 3118 buffer API.

public
PyByteArray(Iterable<? extends PyObject>
source of the bytes (and size)
value
)

Constructs a new array filled from an iterable of PyObject.

public
PyByteArray(PyString
primary argument from which value is taken
arg
,
PyObject
name of optional encoding (must be a string type)
encoding
,
PyObject
name of optional errors policy (must be a string type)
errors
)

Constructs a new array by encoding a PyString argument to bytes.

public
PyByteArray(PyString
primary argument from which value is taken
arg
,
String
name of optional encoding (may be null to select the default for this installation)
encoding
,
String
name of optional errors policy
errors
)

Constructs a new array by encoding a PyString argument to bytes.

public
PyByteArray(PyString
primary argument from which value is taken
arg
)

Constructs a new array by encoding a PyString argument to bytes.

public
PyByteArray(byte[]
pre-initialised with desired value: the caller should not keep a reference
storage
)

Constructs a bytearray by re-using an array of byte as storage initialised by the client.

public
PyByteArray(byte[]
pre-initialised with desired value: the caller should not keep a reference
storage
,
int
number of bytes actually used
size
)

Constructs a bytearray by re-using an array of byte as storage initialised by the client.

public
PyByteArray(PyObject
primary argument from which value is taken (may be null)
arg
)

Constructs a new bytearray object from an arbitrary Python object according to the same rules as apply in Python to the bytearray() constructor:

  • bytearray() Construct a zero-length bytearray.
  • bytearray(int) Construct a zero-initialized bytearray of the given length.
  • bytearray(iterable_of_ints) Construct from iterable yielding integers in [0..255]
  • bytearray(buffer) Construct by reading from any object implementing BufferProtocol, including str/bytes or another bytearray.

Method Summary

Modifier and TypeMethod and Description
public PyObject
__add__(PyObject
the object to perform this binary operation with (the right-hand operand).
o
)

Overrides org.python.core.PyObject.__add__.

Equivalent to the standard Python __add__ method.

public int
__alloc__()

Returns the number of bytes actually allocated.

public boolean

Returns:

the result of the search.
__contains__
(PyObject
the element to search for in this bytearray.
o
)

Overrides org.python.core.PyObject.__contains__.

Implement to the standard Python __contains__ method, which in turn implements the in operator.

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 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
__iadd__(PyObject
the object to perform this binary operation with (the right-hand operand).
o
)

Overrides org.python.core.PyObject.__iadd__.

Equivalent to the standard Python __iadd__ method.

public PyObject
__imul__(PyObject
the object to perform this binary operation with (the right-hand operand).
n
)

Overrides org.python.core.PyObject.__imul__.

Equivalent to the standard Python __imul__ method, that for a byte array returns a new byte array containing the same thing n times.

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 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
__mul__(PyObject
the object to perform this binary operation with (the right-hand operand).
n
)

Overrides org.python.core.PyObject.__mul__.

Equivalent to the standard Python __mul__ method, that for a byte array returns a new byte array containing the same thing n times.

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 PyString
__repr__()

Overrides org.python.core.PyObject.__repr__.

Equivalent to the standard Python __repr__ method.

public PyObject
__rmul__(PyObject
the object to perform this binary operation with (the left-hand operand).
n
)

Overrides org.python.core.PyObject.__rmul__.

Equivalent to the standard Python __rmul__ method, that for a byte array returns a new byte array containing the same thing n times.

public PyString
__str__()

Overrides org.python.core.PyObject.__str__.

An overriding of the PyObject#__str__() method, returning PyString, where in the characters are simply those with a point-codes given in this byte array.

public void
append(byte
the byte to append.
element
)

Append a single byte to the end of the array.

public void
append(PyObject
the item to append.
element
)

Append a single element to the end of the array, equivalent to: s[len(s):len(s)] = o.

pack-priv final synchronized PyObject
pack-priv final int
pack-priv final boolean
pack-priv final synchronized PyObject
pack-priv final synchronized PyObject
pack-priv final synchronized PyObject
pack-priv final synchronized PyObject
pack-priv final int
pack-priv final synchronized PyObject
pack-priv final PyObject
pack-priv final synchronized void
bytearray___init__(PyObject[]
argument array according to Jython conventions
args
,
String[]
Keywords according to Jython conventions
kwds
)

Initialise a mutable bytearray object from various arguments.

pack-priv final synchronized PyObject
pack-priv final int
pack-priv final synchronized PyObject
pack-priv final PyObject
pack-priv final synchronized PyObject
pack-priv final PyObject
pack-priv final synchronized PyString
pack-priv final PyObject
pack-priv final synchronized void
pack-priv final synchronized void
pack-priv final PyByteArray
pack-priv final PyByteArray
bytearray_center(int width, String fillchar)

pack-priv final int
pack-priv final PyObject
bytearray_decode(PyObject[] args, String[] keywords)

pack-priv final boolean
pack-priv final PyByteArray
bytearray_expandtabs(int tabsize)

pack-priv final synchronized void
pack-priv final int
pack-priv static PyByteArray
pack-priv final int
pack-priv final synchronized void
pack-priv final boolean
pack-priv final boolean
pack-priv final boolean
pack-priv final boolean
pack-priv final boolean
pack-priv final boolean
pack-priv final boolean
pack-priv final PyByteArray
pack-priv final PyByteArray
bytearray_ljust(int width, String fillchar)

pack-priv final PyByteArray
pack-priv final synchronized PyByteArray
pack-priv final PyTuple
pack-priv final synchronized PyInteger
pack-priv final synchronized void
pack-priv final PyByteArray
pack-priv final synchronized void
pack-priv final int
pack-priv final int
pack-priv final PyByteArray
bytearray_rjust(int width, String fillchar)

pack-priv final PyTuple
pack-priv final PyList
bytearray_rsplit(PyObject sep, int maxsplit)

pack-priv final synchronized PyByteArray
pack-priv final PyList
bytearray_split(PyObject sep, int maxsplit)

pack-priv final PyList
bytearray_splitlines(boolean keepends)

pack-priv final boolean
pack-priv final PyString
pack-priv final synchronized PyByteArray
pack-priv final PyByteArray
pack-priv final PyByteArray
pack-priv final PyByteArray
pack-priv final PyByteArray
pack-priv final PyByteArray
bytearray_zfill(int width)

public PyByteArray

Returns:

new byte array containing result
center
(int
desired
width
)

Java API equivalent of Python center(width): return the bytes centered in an array of length width, padded by spaces.

public PyByteArray

Returns:

new byte array containing the result
center
(int
desired
width
,
String
one-byte String to fill with, or null implying space
fillchar
)

Java API equivalent of Python center(width [, fillchar]): return the bytes centered in an array of length width.

public int

Returns:

count of occurrences of sub within this byte array
count
(PyObject
sequence to find (of a type viewable as a byte sequence)
sub
)

Implementation of Python count(sub).

public int

Returns:

count of occurrences of sub within this byte array
count
(PyObject
sequence to find (of a type viewable as a byte sequence)
sub
,
PyObject
of slice to search
start
)

Implementation of Python count( sub [, start ] ).

public int

Returns:

count of occurrences of sub within this byte array
count
(PyObject
sequence to find (of a type viewable as a byte sequence)
sub
,
PyObject
of slice to search
start
,
PyObject
of slice to search
end
)

Implementation of Python count( sub [, start [, end ]] ).

protected synchronized void
del(int
index of the element to delete.
index
)

Overrides org.python.core.PySequence.del.

Deletes an element from the sequence (and closes up the gap).

protected synchronized void
delRange(int
the position of the first element.
start
,
int
one more than the position of the last element.
stop
)

Overrides org.python.core.PySequence.delRange.

Deletes a contiguous sub-sequence (and closes up the gap).

protected synchronized void
delslice(int
the position of the first element.
start
,
int
beyond the position of the last element (not necessarily just beyond).
stop
,
int
from one element to the next (positive or negative)
step
,
int
number of elements to delete
n
)

Overrides org.python.core.PySequence.delslice.

Deletes a simple or extended slice and closes up the gap(s).

public boolean

Returns:

true if and only if this bytearray ends with the suffix (or one of them)
endswith
(PyObject
byte array to match, or object viewable as such, or a tuple of them
suffix
)

Implementation of Python endswith(suffix).

public boolean

Returns:

true if and only if this[start:] ends with the suffix (or one of them)
endswith
(PyObject
byte array to match, or object viewable as such, or a tuple of them
suffix
,
PyObject
of slice in this bytearray to match
start
)

Implementation of Python endswith( suffix [, start ] ).

public boolean

Returns:

true if and only if this[start:end] ends with the suffix (or one of them)
endswith
(PyObject
byte array to match, or object viewable as such, or a tuple of them
suffix
,
PyObject
of slice in this bytearray to match
start
,
PyObject
of slice in this bytearray to match
end
)

Implementation of Python endswith( suffix [, start [, end ]] ).

public PyByteArray

Returns:

copy of this byte array with tabs expanded
expandtabs
()

Implementation of Python expandtabs(): return a copy of the byte array where all tab characters are replaced by one or more spaces, as expandtabs(int) with a tab size of 8 characters.

public PyByteArray

Returns:

copy of this byte array with tabs expanded
expandtabs
(int
number of character positions between tab stops
tabsize
)

Implementation of Python expandtabs(tabsize): return a copy of the byte array where all tab characters are replaced by one or more spaces, depending on the current column and the given tab size.

public void
extend(PyObject
the sequence of items to append to the list.
o
)

Append the elements in the argument sequence to the end of the array, equivalent to: s[len(s):len(s)] = o.

public int

Returns:

index of start of occurrence of sub within this byte array
find
(PyObject
sequence to find (of a type viewable as a byte sequence)
sub
)

Implementation of Python find(sub).

public int

Returns:

index of start of occurrence of sub within this byte array
find
(PyObject
sequence to find (of a type viewable as a byte sequence)
sub
,
PyObject
of slice to search
start
)

Implementation of Python find( sub [, start ] ).

public int

Returns:

index of start of occurrence of sub within this byte array
find
(PyObject
sequence to find (of a type viewable as a byte sequence)
sub
,
PyObject
of slice to search
start
,
PyObject
of slice to search
end
)

Implementation of Python find( sub [, start [, end ]] ).

pack-priv static PyByteArray
fromhex(String
specification of the bytes
hex
)

Implementation of Python class method bytearray.fromhex(string), that returns .

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.

private BaseBuffer
getExistingBuffer(int flags)

Try to re-use an existing exported buffer, or return null if we can't.

protected PyByteArray
getResult(BaseBytes.Builder
containing the result
b
)

Implements abstract org.python.core.BaseBytes.getResult.

Every sub-class of BaseBytes overrides this method to access a Builder and return that class' particular type, possibly without copying.

protected synchronized PyByteArray

Returns:

a PyByteArray 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.BaseBytes.getslice.

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

protected synchronized PyByteArray
getslice(int
the position of the first element.
start
,
int
one more than the position of the last element.
stop
)

Overrides org.python.core.BaseBytes.getslice.

Specialisation of getslice(int, int, int) to contiguous slices (of step size 1) for brevity and efficiency.

private PyBuffer

Returns:

the buffer view of the table or null if there is no table
getTranslationTable
(PyObject
the translation table (or null or PyNone)
table
)

Return a PyBuffer representing a translation table, or raise an exception if it is the wrong size.

public int
hashCode()

Overrides org.python.core.BaseBytes.hashCode.

Implements java.util.List.hashCode.

This type is not hashable.

public int

Returns:

index of start of occurrence of sub within this byte array
index
(PyObject
sequence to find (of a type viewable as a byte sequence)
sub
)

Implementation of Python index(sub).

public int

Returns:

index of start of occurrence of sub within this byte array
index
(PyObject
sequence to find (of a type viewable as a byte sequence)
sub
,
PyObject
of slice to search
start
)

Implementation of Python index( sub [, start ] ).

public int

Returns:

index of start of occurrence of sub within this byte array
index
(PyObject
sequence to find (of a type viewable as a byte sequence)
sub
,
PyObject
of slice to search
start
,
PyObject
of slice to search
end
)

Implementation of Python index( sub [, start [, end ]] ).

public void
insert(PyObject
the position where the element will be inserted.
index
,
PyObject
the element to insert.
value
)

Insert the argument element into the byte array at the specified index.

protected synchronized void
irepeat(int
the number of times to repeat this.
count
)

Replace the contents of this PyByteArray with the given number of repeats of the original contents, as in the implementation of __mul__ for strings.

public PyByteArray

Returns:

byte array produced by concatenation.
join
(PyObject
of byte array objects, or objects viewable as such.
iterable
)

Implementation of Python join(iterable).

public PyByteArray

Returns:

new byte array containing result
ljust
(int
desired
width
)

Java API equivalent of Python ljust(width): return the bytes left justified in an array of length width, padded by spaces.

public PyByteArray

Returns:

new byte array containing the result
ljust
(int
desired
width
,
String
one-byte String to fill with, or null implying space
fillchar
)

Java API equivalent of Python ljust(width [, fillchar]): return the bytes left-justified in an array of length width.

public PyByteArray

Returns:

a byte array containing this value stripped of those bytes
lstrip
()

Implementation of Python lstrip().

public PyByteArray

Returns:

a byte array containing this value stripped of those bytes (at the left)
lstrip
(PyObject
treated as a set of bytes defining what values to strip
bytes
)

Implementation of Python lstrip(bytes) Return a copy of the byte array with the leading characters removed.

protected void
newStorage(int
becomes the new value of this.size
needed
)

Overrides org.python.core.BaseBytes.newStorage.

Allocate fresh storage for at least the requested number of bytes.

private void
newStorage(int
length of storage array to allocate (decided by caller)
L2
,
int
length of A
a
,
int
gap between A and B in current storage layout
d
,
int
length of B
b
,
int
gap between A and B in new storage layout.
e
)

Allocate new storage and copy two blocks from the current storage to it.

private void
newStorageAvoided(int
length of A
a
,
int
gap between A and B in current storage layout
d
,
int
length of B
b
,
int
gap between A and B in new storage layout.
e
)

Use the existing storage but move two blocks within it to leave a gap of the required size.

public PyInteger

Returns:

PyInteger representing the value
pop
()

Remove and return the last element in the byte array.

public PyInteger

Returns:

PyInteger representing the value
pop
(int
the index of the byte to remove and return.
i
)

Remove and return the nth byte element in the array.

public synchronized void
pyinsert(int
to insert at
index
,
PyObject
to insert (by value)
element
)

Overrides org.python.core.BaseBytes.pyinsert.

Insert the element (interpreted as a Python byte value) at the given index.

public synchronized void
pyset(int
index of the element to set.
index
,
PyObject
the value to set this element to.
value
)

Overrides org.python.core.PySequence.pyset.

Sets the indexed element of the bytearray to the given value.

private final int

Returns:

recommended amount to allocate
recLength
(int
number of bytes needed
needed
)

Recommend a length for (but don't allocate) a new storage array, taking into account the current length and the number of bytes now needed.

public void
remove(PyObject
the value to remove from the list.
o
)

Remove the first occurrence of an element from the array, equivalent to: del s[s.index(x)], although x must be convertable to a single byte value.

protected synchronized PyByteArray

Returns:

this byte array repeated count times.
repeat
(int
the number of times to repeat this.
count
)

Implements abstract org.python.core.BaseBytes.repeat.

Returns a PyByteArray that repeats this sequence the given number of times, as in the implementation of __mul__ for strings.

public PyByteArray

Returns:

result of replacement as a new PyByteArray
replace
(PyObject
sequence to find
oldB
,
PyObject
relacement sequence
newB
)

An implementation of Python replace( old, new ), returning a PyByteArray with all occurrences of sequence oldB replaced by newB.

public PyByteArray

Returns:

result of replacement as a new PyByteArray
replace
(PyObject
sequence to find
oldB
,
PyObject
relacement sequence
newB
,
int
maximum occurrences are replaced or all if maxcount < 0
maxcount
)

An implementation of Python replace( old, new [, count ] ), returning a PyByteArray with all occurrences of sequence oldB replaced by newB.

protected void
resizeCheck()

Test to see if the byte array may be resized and raise a BufferError if not.

public void
reverse()

Reverses the contents of the byte array in place.

public int

Returns:

index of start of rightmost occurrence of sub within this byte array
rfind
(PyObject
sequence to find (of a type viewable as a byte sequence)
sub
)

Implementation of Python rfind(sub).

public int

Returns:

index of start of rightmost occurrence of sub within this byte array
rfind
(PyObject
sequence to find (of a type viewable as a byte sequence)
sub
,
PyObject
of slice to search
start
)

Implementation of Python rfind( sub [, start ] ).

public int

Returns:

index of start of rightmost occurrence of sub within this byte array
rfind
(PyObject
sequence to find (of a type viewable as a byte sequence)
sub
,
PyObject
of slice to search
start
,
PyObject
of slice to search
end
)

Implementation of Python rfind( sub [, start [, end ]] ).

public int

Returns:

index of start of occurrence of sub within this byte array
rindex
(PyObject
sequence to find (of a type viewable as a byte sequence)
sub
)

Implementation of Python rindex(sub).

public int

Returns:

index of start of occurrence of sub within this byte array
rindex
(PyObject
sequence to find (of a type viewable as a byte sequence)
sub
,
PyObject
of slice to search
start
)

Implementation of Python rindex( sub [, start ] ).

public int

Returns:

index of start of occurrence of sub within this byte array
rindex
(PyObject
sequence to find (of a type viewable as a byte sequence)
sub
,
PyObject
of slice to search
start
,
PyObject
of slice to search
end
)

Implementation of Python rindex( sub [, start [, end ]] ).

public PyByteArray

Returns:

new byte array containing result
rjust
(int
desired
width
)

Java API equivalent of Python rjust(width): return the bytes right justified in an array of length width, padded by spaces.

public PyByteArray

Returns:

new byte array containing the result
rjust
(int
desired
width
,
String
one-byte String to fill with, or null implying space
fillchar
)

Java API equivalent of Python rjust(width [, fillchar]): return the bytes right-justified in an array of length width.

public PyByteArray

Returns:

a byte array containing this value stripped of those bytes (at right)
rstrip
()

Implementation of Python rstrip().

public PyByteArray

Returns:

a byte array containing this value stripped of those bytes (at right)
rstrip
(PyObject
treated as a set of bytes defining what values to strip
bytes
)

Implementation of Python rstrip(bytes) Return a copy of the byte array with the trailing characters removed.

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.

private 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
,
int
number of zeros to insert consistent with the slice assignment
len
)

Sets the given range of elements according to Python slice assignment semantics from a zero-filled bytearray of the given length.

private 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
,
PyString
a PyString object consistent with the slice assignment
value
)

Sets the given range of elements according to Python slice assignment semantics from a PyString that is not a PyUnicode.

private 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
,
BufferProtocol
an object supporting the buffer API consistent with the slice assignment
value
)

Sets the given range of elements according to Python slice assignment semantics from an object supporting the Jython implementation of PEP 3118.

private 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
,
BaseBytes
a bytearray (or bytes) object consistent with the slice assignment
value
)

Sets the given range of elements according to Python slice assignment semantics from a bytearray (or bytes).

private 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
,
Iterable<? extends PyObject>
iterable source of values to enter in the array
iter
)

Sets the given range of elements according to Python slice assignment semantics from a bytearray (or bytes).

private boolean

Returns:

true if the slice was set successfully, false otherwise
setsliceFromBuffer
(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 possibly bearing the Buffer API
value
)

Sets the given range of elements according to Python slice assignment semantics from an object that might support the Jython Buffer API.

public static PyException

Returns:

PyException (ValueError) as detailed
SliceSizeError
(String valueType, int
size of sequence being assigned to slice
valueSize
,
int
size of slice expected to receive
sliceSize
)

Convenience method to build (but not throw) a ValueError PyException with the message "attempt to assign {type} of size {valueSize} to extended slice of size {sliceSize}"

public boolean

Returns:

true if and only if this bytearray starts with the prefix (or one of them)
startswith
(PyObject
byte array to match, or object viewable as such, or a tuple of them
prefix
)

Implementation of Python startswith(prefix).

public boolean

Returns:

true if and only if this[start:] starts with the prefix (or one of them)
startswith
(PyObject
byte array to match, or object viewable as such, or a tuple of them
prefix
,
PyObject
of slice in this bytearray to match
start
)

Implementation of Python startswith( prefix [, start ] ).

public boolean

Returns:

true if and only if this[start:end] starts with the prefix (or one of them)
startswith
(PyObject
byte array to match, or object viewable as such, or a tuple of them
prefix
,
PyObject
of slice in this bytearray to match
start
,
PyObject
of slice in this bytearray to match
end
)

Implementation of Python startswith( prefix [, start [, end ]] ).

private void
storageDelete(int
index of hole in byte array
a
,
int
number to discard (will discard x[a,a+d-1])
d
)

Delete d elements at index a by moving together the surrounding elements.

private void
storageExtend(int
size of hole to open (will be x[a, a+e-1]) where a = size before call
e
)

Prepare to insert e elements at the end of the storage currently in use.

private void
storageReplace(int
index of hole in byte array
a
,
int
number to discard (will discard x[a,a+d-1])
d
,
int
size of hole to open (will be x[a, a+e-1])
e
)

Delete d elements at index a and prepare to insert e elements there by moving aside the surrounding elements.

public PyByteArray

Returns:

a byte array containing this value stripped of those bytes (left and right)
strip
()

Implementation of Python strip().

public PyByteArray

Returns:

a byte array containing this value stripped of those bytes (left and right)
strip
(PyObject
treated as a set of bytes defining what values to strip
bytes
)

Implementation of Python strip(bytes) Return a copy of the byte array with the leading and trailing characters removed.

public String
toString()

Overrides org.python.core.PyObject.toString.

An overriding of the standard Java toString() method, returning a printable expression of this byte array in the form bytearray(b'hello'), where in the "inner string", any special characters are escaped to their well-known backslash equivalents or a hexadecimal escape.

public PyByteArray

Returns:

translated byte array
translate
(PyObject
length 256 translation table (of a type that may be regarded as a byte array)
table
)

Implementation of Python translate(table).

public PyByteArray

Returns:

translated byte array
translate
(PyObject
length 256 translation table (of a type that may be regarded as a byte array)
table
,
PyObject
object that may be regarded as a byte array, defining bytes to delete
deletechars
)

Implementation of Python translate(table[, deletechars]).

public PyByteArray

Returns:

left-filled byte array
zfill
(int
desired
width
)

Implementation of Python zfill(width): return the numeric string left filled with zeros in a byte array of length width.

Inherited from org.python.core.BaseBytes:
__len____reduce__addaddaddAlladdAllasStringbasebytes___contains__basebytes___eq__basebytes___ge__basebytes___gt__basebytes___le__basebytes___lt__basebytes___ne__basebytes___reduce__basebytes_capitalizebasebytes_centerbasebytes_countbasebytes_decodebasebytes_expandtabsbasebytes_findbasebytes_fromhexbasebytes_isalnumbasebytes_isalphabasebytes_isdigitbasebytes_islowerbasebytes_isspacebasebytes_istitlebasebytes_isupperbasebytes_joinbasebytes_ljustbasebytes_lowerbasebytes_partitionbasebytes_replacebasebytes_reprbasebytes_rfindbasebytes_rjustbasebytes_rpartitionbasebytes_rsplitbasebytes_rsplit_explicitbasebytes_rsplit_whitespacebasebytes_splitbasebytes_split_explicitbasebytes_split_whitespacebasebytes_splitlinesbasebytes_starts_or_endswithbasebytes_swapcasebasebytes_titlebasebytes_upperbasebytes_zfillbyteCheckbyteCheckbyteCheckcapitalizecheckForEmptySeparatorclearConcatenationTypeErrorcontainscontainsAlldecodedecodedecodeencodeequalsfillByteCheckgetgetViewgetViewOrErrorindexindexCheckindexOfinitinitinitinitinitinitinitintAtisalnumisalnumisalphaisalphaisdigitisdigitisEmptyislowerislowerisspaceisspaceistitleisupperisupperiteratorlastIndexOflistIteratorlistIteratorlowerlstripIndexlstripIndexpartitionpygetremoveremoveremoveAllretainAllroundUprpartitionrsplitrsplitrsplitrstripIndexrstripIndexsetsetBytessetBytessetStoragesetStoragesetStoragesizesplitsplitsplitsplitlinessplitlinessubListswapcasetitletoArraytoArrayupper