picop.cylist#

Fast list accessors.

picop.cylist.list_append(l, value)#

Append value via PyList_Append.

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.cylist.list_as_tuple(l)#

Return tuple(l) via PyList_AsTuple. :type l: list :param l:

Return type:

tuple

picop.cylist.list_check(p)#

Return True if p is a list or subtype (PyList_Check). :type p: object :param p:

Return type:

bool

Parameters:

p (object)

picop.cylist.list_check_exact(p)#

Return True if type(p) is list (PyList_CheckExact). :type p: object :param p:

Return type:

bool

Parameters:

p (object)

picop.cylist.list_clear(l)#

Clear l via PyList_Clear.

Notes

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

Parameters:

l (list)

Return type:

int

picop.cylist.list_copy(l)#

Return a shallow copy of l via PyList_GetSlice. :type l: list :param l:

Return type:

list

picop.cylist.list_empty()#

Return a new empty list via PyList_New(0).

Return type:

list

picop.cylist.list_eq(a, b)#

Return True if typed lists are equal (identity/len short-circuit + richcompare). :type a: list :param a: :type b: list :param b:

Return type:

bool

Parameters:
picop.cylist.list_extend(l, iterable)#

Extend l from iterable via PyList_Extend.

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.cylist.list_get(l, i)#

Return l[i] via PyList_GET_ITEM.

Notes

Unchecked: out-of-bounds is undefined behavior. Prefer list_get_checked / list_get_ref when the index may be OOB, or bound the index yourself before calling.

Parameters:
Return type:

object

picop.cylist.list_get_checked(l, i)#

Return l[i] via bounds-checked PyList_GetItem.

Notes

Raises IndexError on out-of-bounds (unlike unchecked list_get).

Parameters:
Return type:

object

picop.cylist.list_get_ref(l, i)#

Return a strong ref to l[i] via PyList_GetItemRef.

Notes

Raises IndexError on out-of-bounds (unlike unchecked list_get).

Parameters:
Return type:

object

picop.cylist.list_insert(l, i, value)#

Insert value at i via PyList_Insert.

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.cylist.list_len(l)#

Return len(l) via PyList_GET_SIZE. :type l: list :param l:

Return type:

int

Parameters:

l (list)

picop.cylist.list_reverse(l)#

Reverse l in place via PyList_Reverse.

Notes

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

Parameters:

l (list)

Return type:

int

picop.cylist.list_set_item(l, i, value)#

Set l[i] = value via PyList_SetItem.

Notes

INCREFs value then steals the new reference into the list slot. Returns 0 on success and -1 on error; errors raise. Do not use the status int as a bool.

Parameters:
Return type:

int

picop.cylist.list_set_slice(l, low, high, itemlist=None)#

Assign l[low:high] = itemlist via PyList_SetSlice.

Notes

Pass None for itemlist to delete the slice. Returns 0 on success and -1 on error; errors raise. Do not use the status int as a bool.

Parameters:
Return type:

int

picop.cylist.list_size(l)#

Return len(l) via checked PyList_Size.

Notes

Prefer list_len on a typed list hot path.

Parameters:

l (object)

Return type:

int

picop.cylist.list_slice(l, low, high)#

Return l[low:high] via PyList_GetSlice. :type l: list :param l: :type low: int :param low: :type high: int :param high:

Return type:

list

picop.cylist.list_sort(l)#

Sort l in place via PyList_Sort.

Notes

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

Parameters:

l (list)

Return type:

int