cbytesparse.py.BytesMethods

class cbytesparse.py.BytesMethods(wrapped)[source]

Provides useful methods to a byte buffer.

Python’s memoryview and most byte-like objects do not provide many useful methods found instead within the bytes or str APIs.

This wrapper class adds a low-level implementation of those methods to anything supporting the buffer protocol.

Parameters:

wrapped (byte-like) – The target object supporting the buffer protocol.

Examples

>>> from cbytesparse import BytesMethods
>>> import numpy
>>> numbers = list(b'ABC')
>>> numbers
[65, 66, 67]
>>> data = numpy.array(numbers, dtype=numpy.ubyte)
>>> data
array([65, 66, 67], dtype=uint8)
>>> data.lower()  # noqa
Traceback (most recent call last):
    ...
AttributeError: 'numpy.ndarray' object has no attribute 'lower'
>>> wrapped = BytesMethods(data)  # noqa
>>> bytes(wrapped.lower())
b'abc'
>>> wrapped = BytesMethods(memoryview(data))
>>> bytes(wrapped.lower())
b'abc'

Methods

__init__

capitalize

byte-like: First character capitalized, the rest lowercase.

center

Return a centered string of length width.

contains

Contains a substring.

count

Counts token occurrences.

decode

Decode the bytes using the codec registered for encoding.

endswith

Return True if B ends with the specified suffix, False otherwise.

find

Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end].

index

Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end].

isalnum

Return True if all characters in B are alphanumeric and there is at least one character in B, False otherwise.

isalpha

Return True if all characters in B are alphabetic and there is at least one character in B, False otherwise.

isascii

Return True if B is empty or all characters in B are ASCII, False otherwise.

isdecimal

Return True if the string is a decimal string, False otherwise.

isdigit

Return True if all characters in B are digits and there is at least one character in B, False otherwise.

isidentifier

Return True if the string is a valid Python identifier, False otherwise.

islower

Return True if all cased characters in B are lowercase and there is at least one cased character in B, False otherwise.

isnumeric

Return True if the string is a numeric string, False otherwise.

isprintable

Return True if the string is printable, False otherwise.

isspace

Return True if all characters in B are whitespace and there is at least one character in B, False otherwise.

istitle

Return True if B is a titlecased string and there is at least one character in B, i.e. uppercase characters may only follow uncased characters and lowercase characters only cased ones.

isupper

Return True if all cased characters in B are uppercase and there is at least one cased character in B, False otherwise.

ljust

Return a left-justified string of length width.

lower

Return a copy of B with all ASCII characters converted to lowercase.

lstrip

Strip leading bytes contained in the argument.

maketrans

Return a translation table useable for the bytes or bytearray translate method.

partition

Partition the bytes into three parts using the given separator.

release

Release the underlying buffer exposed by the memoryview object.

removeprefix

Return a bytes object with the given prefix string removed if present.

removesuffix

Return a bytes object with the given suffix string removed if present.

replace

Return a copy with all occurrences of substring old replaced by new.

rfind

Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end].

rindex

Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end].

rjust

Return a right-justified string of length width.

rpartition

Partition the bytes into three parts using the given separator.

rstrip

Strip trailing bytes contained in the argument.

startswith

Return True if B starts with the specified prefix, False otherwise.

strip

Strip leading and trailing bytes contained in the argument.

swapcase

Return a copy of B with uppercase ASCII characters converted to lowercase ASCII and vice versa.

title

Return a titlecased version of B, i.e. ASCII words start with uppercase characters, all remaining cased characters have lowercase.

tobytes

Return the data in the buffer as a byte string.

tolist

Return the data in the buffer as a list of elements.

translate

Return a copy with each character mapped by the given translation table.

upper

Return a copy of B with all ASCII characters converted to uppercase.

zfill

Pad a numeric string with zeros on the left, to fill a field of the given width.

Attributes

c_contiguous

Contiguous array, C language style.

contiguous

Contiguous array.

f_contiguous

Contiguous array, Fortran language style.

format

A string containing the format (in struct module style)

itemsize

The size in bytes of each element of the memoryview.

nbytes

The amount of space in bytes that the array would use in

ndim

An integer indicating how many dimensions of a multi-dimensional

obj

The underlying object of the memoryview.

readonly

A bool indicating whether the memory is read only.

shape

A tuple of ndim integers giving the shape of the memory

strides

A tuple of ndim integers giving the size in bytes to access

suboffsets

A tuple of integers used internally for PIL-style arrays.

__bool__()[source]

Has any items.

Returns:

bool – Has any items.

Examples

>>> from cbytesparse import BytesMethods
>>> instance = BytesMethods(b'')
>>> bool(instance)
False
>>> instance = BytesMethods(b'Hello, World!')
>>> bool(instance)
True
__bytes__()[source]

Creates a bytes clone.

Returns:

bytes – Cloned data.

Examples

>>> from cbytesparse import BytesMethods
>>> instance = BytesMethods(bytearray(b''))
>>> bytes(instance)
b''
>>> instance = BytesMethods(bytearray(b'Hello, World!'))
>>> bytes(instance)
b'Hello, World!'
classmethod __class_getitem__(params)

Parameterizes a generic class.

At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.

However, note that this method is also called when defining generic classes in the first place with class Foo(Generic[T]): ….

__contains__(token)[source]

Checks if some items are contained.

Parameters:

token (byte-like) – Token to find.

Returns:

bool – Token is contained.

Examples

>>> from cbytesparse import BytesMethods
>>> instance = BytesMethods(b'Hello, World!')
>>> b'World' in instance
True
>>> b'$' in instance
False
>>> ord('o') in instance
True
>>> ord('$') in instance
False
__eq__(other)[source]

Equality comparison.

Parameters:

other (byte-like) – Data to compare with self.

Returns:

boolself is equal to other.

Examples

>>> from cbytesparse import BytesMethods
>>> data = bytearray(b'Hello, World!')
>>> instance = BytesMethods(data)
>>> instance == data
True
>>> instance == memoryview(data)
True
>>> instance == b'Something else'
False
__ge__(other)[source]

Return self>=value.

Warning

This method documentation is just a stub, copied directly from bytes.__ge__(). It may be incomplete, or with different arguments. The behavior should be very similar though.

__getitem__(key)[source]

Gets data.

Parameters:

key (slice or int) – Selection range or address. If it is a slice with bytes-like step, the latter is interpreted as the filling pattern.

Returns:

items – Items from the requested range.

Examples

>>> from cbytesparse import BytesMethods
>>> instance = BytesMethods(b'Hello, World!')
>>> instance[7]  # -> ord('W') = 87
121
>>> bytes(instance[:3])
b'Hel'
>>> bytes(instance[3:10])
b'lo, Wor'
>>> bytes(instance[-1:])
b'!'
>>> bytes(instance[2:10:3])
b'l,o'
>>> bytes(instance[3:10:2])
b'l,Wr'
__gt__(other)[source]

Return self>value.

Warning

This method documentation is just a stub, copied directly from bytes.__gt__(). It may be incomplete, or with different arguments. The behavior should be very similar though.

__hash__ = None
__init__(wrapped)[source]
classmethod __init_subclass__(*args, **kwargs)

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__iter__()[source]

Iterates over values.

Yields:

int – Value as byte integer.

Examples

>>> from cbytesparse import BytesMethods
>>> instance = BytesMethods(b'Hello, World!')
>>> list(instance)
[72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]
__le__(other)[source]

Return self<=value.

Warning

This method documentation is just a stub, copied directly from bytes.__le__(). It may be incomplete, or with different arguments. The behavior should be very similar though.

__len__()[source]

Actual length.

Computes the actual length of the wrapped data object.

Returns:

int – Data length.

Examples

>>> from cbytesparse import BytesMethods
>>> instance = BytesMethods(b'')
>>> len(instance)
0
>>> instance = BytesMethods(bytes(7))
>>> len(instance)
7
>>> instance = BytesMethods(memoryview(b'Hello, World!'))
>>> len(instance)
13
__lt__(other)[source]

Return self<value.

Warning

This method documentation is just a stub, copied directly from bytes.__lt__(). It may be incomplete, or with different arguments. The behavior should be very similar though.

__ne__(other)[source]

Inquality comparison.

Parameters:

other (byte-like) – Data to compare with self.

Returns:

boolself is not equal to other.

Examples

>>> from cbytesparse import BytesMethods
>>> data = bytearray(b'Hello, World!')
>>> instance = BytesMethods(data)
>>> instance != data
False
>>> instance != memoryview(data)
False
>>> instance != b'Something else'
True
__reversed__()[source]

Iterates over values, reversed order.

Yields:

int – Value as byte integer.

Examples

>>> from cbytesparse import BytesMethods
>>> instance = BytesMethods(b'Hello, World!')
>>> list(instance)
[72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]
>>> list(reversed(instance))
[33, 100, 108, 114, 111, 87, 32, 44, 111, 108, 108, 101, 72]
__sizeof__()[source]

int: Allocated byte size.

classmethod __subclasshook__(C)

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

property c_contiguous: bool

Contiguous array, C language style.

Type:

bool

capitalize()[source]

byte-like: First character capitalized, the rest lowercase.

center(width, fillchar=b' ', factory=<class 'bytes'>)[source]

Return a centered string of length width.

Padding is done using the specified fill character.

Warning

This method documentation is just a stub, copied directly from bytes.center(). It may be incomplete, or with different arguments. The behavior should be very similar though.

contains(token, start=None, endex=None)[source]

Contains a substring.

Parameters:
  • token (byte-like) – Token to search.

  • start (int) – Inclusive start of the searched range, None to ignore.

  • endex (int) – Exclusive end of the searched range, None to ignore.

Returns:

bool – Token contained within the wrapped object.

See also

__contains__()

Examples

>>> from cbytesparse import BytesMethods
>>> instance = BytesMethods(b'Hello, World!')
>>> instance.contains(b'World')
True
>>> instance.contains(b'$')
False
>>> instance.contains(ord('o'))
True
>>> instance.contains(ord('$'))
False
>>> instance.contains(b'Hello', endex=10)
True
>>> instance.contains(b'Hello', endex=3)
False
>>> instance.contains(b'World', start=3)
True
>>> instance.contains(b'World', start=10)
False
>>> instance.contains(b',', start=3, endex=10)
True
>>> instance.contains(b',', start=8, endex=10)
False
property contiguous: bool

Contiguous array.

Type:

bool

count(token, start=None, endex=None)[source]

Counts token occurrences.

Parameters:
  • token (byte-like) – Token to count.

  • start (int) – Inclusive start of the searched range, None to ignore.

  • endex (int) – Exclusive end of the searched range, None to ignore.

Returns:

int – The number of items equal to token.

Examples

>>> from cbytesparse import BytesMethods
>>> instance = BytesMethods(b'Hello, World!')
>>> instance.count(b'o')
2
>>> instance.count(b'l')
3
>>> instance.count(b'll')
3
>>> instance.count(b'World')
1
>>> instance.count(b'$')
0
>>> instance.count(ord('o'))
1
>>> instance.count(ord('$'))
0
>>> instance.count(b'Hello', endex=10)
1
>>> instance.count(b'Hello', endex=3)
0
>>> instance.count(b'World', start=3)
1
>>> instance.count(b'World', start=10)
0
>>> instance.count(b',', start=3, endex=10)
1
>>> instance.count(b',', start=8, endex=10)
0
decode(encoding='utf-8', errors='strict')[source]

Decode the bytes using the codec registered for encoding.

encoding

The encoding with which to decode the bytes.

errors

The error handling scheme to use for the handling of decoding errors. The default is ‘strict’ meaning that decoding errors raise a UnicodeDecodeError. Other possible values are ‘ignore’ and ‘replace’ as well as any other name registered with codecs.register_error that can handle UnicodeDecodeErrors.

Warning

This method documentation is just a stub, copied directly from bytes.decode(). It may be incomplete, or with different arguments. The behavior should be very similar though.

endswith(token)[source]

Return True if B ends with the specified suffix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. suffix can also be a tuple of bytes to try.

Warning

This method documentation is just a stub, copied directly from bytes.endswith(). It may be incomplete, or with different arguments. The behavior should be very similar though.

property f_contiguous: bool

Contiguous array, Fortran language style.

Type:

bool

find(token, start=None, endex=None)[source]

Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

Warning

This method documentation is just a stub, copied directly from bytes.find(). It may be incomplete, or with different arguments. The behavior should be very similar though.

property format: str
A string containing the format (in struct module style)

for each element in the view.

Warning

This method documentation is just a stub, copied directly from memoryview.format(). It may be incomplete, or with different arguments. The behavior should be very similar though.

index(token, start=None, endex=None)[source]

Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the subsection is not found.

Warning

This method documentation is just a stub, copied directly from bytes.index(). It may be incomplete, or with different arguments. The behavior should be very similar though.

isalnum()[source]

Return True if all characters in B are alphanumeric and there is at least one character in B, False otherwise.

Warning

This method documentation is just a stub, copied directly from bytes.isalnum(). It may be incomplete, or with different arguments. The behavior should be very similar though.

isalpha()[source]

Return True if all characters in B are alphabetic and there is at least one character in B, False otherwise.

Warning

This method documentation is just a stub, copied directly from bytes.isalpha(). It may be incomplete, or with different arguments. The behavior should be very similar though.

isascii()[source]

Return True if B is empty or all characters in B are ASCII, False otherwise.

Warning

This method documentation is just a stub, copied directly from bytes.isascii(). It may be incomplete, or with different arguments. The behavior should be very similar though.

isdecimal()[source]

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

Warning

This method documentation is just a stub, copied directly from str.isdecimal(). It may be incomplete, or with different arguments. The behavior should be very similar though.

isdigit()[source]

Return True if all characters in B are digits and there is at least one character in B, False otherwise.

Warning

This method documentation is just a stub, copied directly from bytes.isdigit(). It may be incomplete, or with different arguments. The behavior should be very similar though.

isidentifier()[source]

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

Warning

This method documentation is just a stub, copied directly from str.isidentifier(). It may be incomplete, or with different arguments. The behavior should be very similar though.

islower()[source]

Return True if all cased characters in B are lowercase and there is at least one cased character in B, False otherwise.

Warning

This method documentation is just a stub, copied directly from bytes.islower(). It may be incomplete, or with different arguments. The behavior should be very similar though.

isnumeric()[source]

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

Warning

This method documentation is just a stub, copied directly from str.isnumeric(). It may be incomplete, or with different arguments. The behavior should be very similar though.

isprintable()[source]

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

Warning

This method documentation is just a stub, copied directly from str.isprintable(). It may be incomplete, or with different arguments. The behavior should be very similar though.

isspace()[source]

Return True if all characters in B are whitespace and there is at least one character in B, False otherwise.

Warning

This method documentation is just a stub, copied directly from bytes.isspace(). It may be incomplete, or with different arguments. The behavior should be very similar though.

istitle()[source]

Return True if B is a titlecased string and there is at least one character in B, i.e. uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return False otherwise.

Warning

This method documentation is just a stub, copied directly from bytes.istitle(). It may be incomplete, or with different arguments. The behavior should be very similar though.

isupper()[source]

Return True if all cased characters in B are uppercase and there is at least one cased character in B, False otherwise.

Warning

This method documentation is just a stub, copied directly from bytes.isupper(). It may be incomplete, or with different arguments. The behavior should be very similar though.

property itemsize: int

The size in bytes of each element of the memoryview.

Warning

This method documentation is just a stub, copied directly from memoryview.itemsize(). It may be incomplete, or with different arguments. The behavior should be very similar though.

ljust(width, fillchar=b' ', factory=<class 'bytes'>)[source]

Return a left-justified string of length width.

Padding is done using the specified fill character.

Warning

This method documentation is just a stub, copied directly from bytes.ljust(). It may be incomplete, or with different arguments. The behavior should be very similar though.

lower()[source]

Return a copy of B with all ASCII characters converted to lowercase.

Warning

This method documentation is just a stub, copied directly from bytes.lower(). It may be incomplete, or with different arguments. The behavior should be very similar though.

lstrip(chars=None, factory=<class 'bytes'>)[source]

Strip leading bytes contained in the argument.

If the argument is omitted or None, strip leading ASCII whitespace.

Warning

This method documentation is just a stub, copied directly from bytes.lstrip(). It may be incomplete, or with different arguments. The behavior should be very similar though.

static maketrans(chars_from, chars_to)[source]

Return a translation table useable for the bytes or bytearray translate method.

The returned table will be one where each byte in frm is mapped to the byte at the same position in to.

The bytes objects frm and to must be of the same length.

Warning

This method documentation is just a stub, copied directly from bytes.maketrans(). It may be incomplete, or with different arguments. The behavior should be very similar though.

property nbytes: int
The amount of space in bytes that the array would use in

a contiguous representation.

Warning

This method documentation is just a stub, copied directly from memoryview.nbytes(). It may be incomplete, or with different arguments. The behavior should be very similar though.

property ndim: int
An integer indicating how many dimensions of a multi-dimensional

array the memory represents.

Warning

This method documentation is just a stub, copied directly from memoryview.ndim(). It may be incomplete, or with different arguments. The behavior should be very similar though.

property obj: ByteString | memoryview | None

The underlying object of the memoryview.

Warning

This method documentation is just a stub, copied directly from memoryview.obj(). It may be incomplete, or with different arguments. The behavior should be very similar though.

partition(sep, factory=<class 'bytes'>)[source]

Partition the bytes into three parts using the given separator.

This will search for the separator sep in the bytes. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original bytes object and two empty bytes objects.

Warning

This method documentation is just a stub, copied directly from bytes.partition(). It may be incomplete, or with different arguments. The behavior should be very similar though.

property readonly: bool

A bool indicating whether the memory is read only.

Warning

This method documentation is just a stub, copied directly from memoryview.readonly(). It may be incomplete, or with different arguments. The behavior should be very similar though.

release()[source]

Release the underlying buffer exposed by the memoryview object.

Warning

This method documentation is just a stub, copied directly from memoryview.release(). It may be incomplete, or with different arguments. The behavior should be very similar though.

removeprefix(prefix, factory=<class 'bytes'>)[source]

Return a bytes object with the given prefix string removed if present.

If the bytes starts with the prefix string, return bytes[len(prefix):]. Otherwise, return a copy of the original bytes.

Warning

This method documentation is just a stub, copied directly from bytes.removeprefix(). It may be incomplete, or with different arguments. The behavior should be very similar though.

removesuffix(suffix, factory=<class 'bytes'>)[source]

Return a bytes object with the given suffix string removed if present.

If the bytes ends with the suffix string and that suffix is not empty, return bytes[:-len(prefix)]. Otherwise, return a copy of the original bytes.

Warning

This method documentation is just a stub, copied directly from bytes.removesuffix(). It may be incomplete, or with different arguments. The behavior should be very similar though.

replace(old, new, count=None, start=None, endex=None)[source]

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

Warning

This method documentation is just a stub, copied directly from bytes.replace(). It may be incomplete, or with different arguments. The behavior should be very similar though.

rfind(token, start=None, endex=None)[source]

Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

Warning

This method documentation is just a stub, copied directly from bytes.rfind(). It may be incomplete, or with different arguments. The behavior should be very similar though.

rindex(token, start=None, endex=None)[source]

Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Raise ValueError when the subsection is not found.

Warning

This method documentation is just a stub, copied directly from bytes.rindex(). It may be incomplete, or with different arguments. The behavior should be very similar though.

rjust(width, fillchar=b' ', factory=<class 'bytes'>)[source]

Return a right-justified string of length width.

Padding is done using the specified fill character.

Warning

This method documentation is just a stub, copied directly from bytes.rjust(). It may be incomplete, or with different arguments. The behavior should be very similar though.

rpartition(sep, factory=<class 'bytes'>)[source]

Partition the bytes into three parts using the given separator.

This will search for the separator sep in the bytes, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty bytes objects and the original bytes object.

Warning

This method documentation is just a stub, copied directly from bytes.rpartition(). It may be incomplete, or with different arguments. The behavior should be very similar though.

rstrip(chars=None, factory=<class 'bytes'>)[source]

Strip trailing bytes contained in the argument.

If the argument is omitted or None, strip trailing ASCII whitespace.

Warning

This method documentation is just a stub, copied directly from bytes.rstrip(). It may be incomplete, or with different arguments. The behavior should be very similar though.

property shape: Tuple[int]
A tuple of ndim integers giving the shape of the memory

as an N-dimensional array.

Warning

This method documentation is just a stub, copied directly from memoryview.shape(). It may be incomplete, or with different arguments. The behavior should be very similar though.

startswith(token)[source]

Return True if B starts with the specified prefix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. prefix can also be a tuple of bytes to try.

Warning

This method documentation is just a stub, copied directly from bytes.startswith(). It may be incomplete, or with different arguments. The behavior should be very similar though.

property strides: Tuple[int]
A tuple of ndim integers giving the size in bytes to access

each element for each dimension of the array.

Warning

This method documentation is just a stub, copied directly from memoryview.strides(). It may be incomplete, or with different arguments. The behavior should be very similar though.

strip(chars=None, factory=<class 'bytes'>)[source]

Strip leading and trailing bytes contained in the argument.

If the argument is omitted or None, strip leading and trailing ASCII whitespace.

Warning

This method documentation is just a stub, copied directly from bytes.strip(). It may be incomplete, or with different arguments. The behavior should be very similar though.

property suboffsets: Tuple

A tuple of integers used internally for PIL-style arrays.

Warning

This method documentation is just a stub, copied directly from memoryview.suboffsets(). It may be incomplete, or with different arguments. The behavior should be very similar though.

swapcase()[source]

Return a copy of B with uppercase ASCII characters converted to lowercase ASCII and vice versa.

Warning

This method documentation is just a stub, copied directly from bytes.swapcase(). It may be incomplete, or with different arguments. The behavior should be very similar though.

title()[source]

Return a titlecased version of B, i.e. ASCII words start with uppercase characters, all remaining cased characters have lowercase.

Warning

This method documentation is just a stub, copied directly from bytes.title(). It may be incomplete, or with different arguments. The behavior should be very similar though.

tobytes()[source]

Return the data in the buffer as a byte string.

Order can be {‘C’, ‘F’, ‘A’}. When order is ‘C’ or ‘F’, the data of the original array is converted to C or Fortran order. For contiguous views, ‘A’ returns an exact copy of the physical memory. In particular, in-memory Fortran order is preserved. For non-contiguous views, the data is converted to C first. order=None is the same as order=’C’.

Warning

This method documentation is just a stub, copied directly from memoryview.tobytes(). It may be incomplete, or with different arguments. The behavior should be very similar though.

tolist()[source]

Return the data in the buffer as a list of elements.

Warning

This method documentation is just a stub, copied directly from memoryview.tolist(). It may be incomplete, or with different arguments. The behavior should be very similar though.

translate(table)[source]

Return a copy with each character mapped by the given translation table.

table

Translation table, which must be a bytes object of length 256.

All characters occurring in the optional argument delete are removed. The remaining characters are mapped through the given translation table.

Warning

This method documentation is just a stub, copied directly from bytes.translate(). It may be incomplete, or with different arguments. The behavior should be very similar though.

upper()[source]

Return a copy of B with all ASCII characters converted to uppercase.

Warning

This method documentation is just a stub, copied directly from bytes.upper(). It may be incomplete, or with different arguments. The behavior should be very similar though.

zfill(width, factory=<class 'bytes'>)[source]

Pad a numeric string with zeros on the left, to fill a field of the given width.

The original string is never truncated.

Warning

This method documentation is just a stub, copied directly from bytes.zfill(). It may be incomplete, or with different arguments. The behavior should be very similar though.