picop.cybytearray#

Fast bytearray accessors.

picop.cybytearray.bytearray_check(p)#

Return True if p is a bytearray or subtype (PyByteArray_Check). :type p: object :param p:

Return type:

bool

Parameters:

p (object)

picop.cybytearray.bytearray_check_exact(p)#

Return True if type(p) is bytearray (PyByteArray_CheckExact). :type p: object :param p:

Return type:

bool

Parameters:

p (object)

picop.cybytearray.bytearray_concat(a, b)#

Return a new bytearray concatenating a and b via PyByteArray_Concat. :type a: object :param a: :type b: object :param b:

Return type:

bytearray

picop.cybytearray.bytearray_contains(haystack, needle)#

Return True if needle is found in typed haystack.

Notes

Mirrors bytes_contains search strategy on a typed bytearray.

Parameters:
Return type:

bool

picop.cybytearray.bytearray_eq(a, b)#

Return True if typed bytearray values are equal.

Notes

Identity/len short-circuit plus memcmp.

Parameters:
Return type:

bool

picop.cybytearray.bytearray_from_object(o)#

Return bytearray(o) via PyByteArray_FromObject (buffer protocol). :type o: object :param o:

Return type:

bytearray

picop.cybytearray.bytearray_len(ba)#

Return len(ba) via PyByteArray_GET_SIZE. :type ba: bytearray :param ba:

Return type:

int

Parameters:

ba (bytearray)

picop.cybytearray.bytearray_ne(a, b)#

Return True if typed bytearray values differ (not bytearray_eq). :type a: bytearray :param a: :type b: bytearray :param b:

Return type:

bool

Parameters:
picop.cybytearray.bytearray_resize(ba, n)#

Resize ba in place via PyByteArray_Resize.

Notes

Returns 0 on success and -1 on error; errors raise. Do not use the status int as a bool.

Parameters:
Return type:

int

picop.cybytearray.bytearray_size(ba)#

Return len(ba) via checked PyByteArray_Size.

Notes

Prefer bytearray_len on a typed bytearray hot path.

Parameters:

ba (object)

Return type:

int