picop.containers#
Category facade: typed Core containers (dict / list / set / tuple).
Prefer from picop.hot import … for micro-opt starters. This module groups
word-prefix container helpers for discovery without a flat barrel dump.
See Safety for unchecked accessors.
- picop.containers.dict_check(p)#
Return True if
pis adictor subtype (PyDict_Check). :type p:object:param p:- Return type:
- picop.containers.dict_check_exact(p)#
Return True if
type(p) is dict(PyDict_CheckExact). :type p:object:param p:- Return type:
- picop.containers.dict_get(d, key)#
Return
d[key]via borrowedPyDict_GetItem.Notes
Missing keys and stored
Noneboth yieldNone. Preferdict_get_refwhen you need to distinguish those cases.
- picop.containers.dict_get_ref(d, key)#
Return a strong ref to
d[key]viaPyDict_GetItemRef.Notes
Missing keys yield
None; a storedNoneis a distinct strong ref toNone. Prefer this overdict_getwhen that distinction matters.
- picop.containers.dict_contains(d, key)#
Return whether
keyis ind(PyDict_Contains). :type d:dict:param d: :type key:str:param key:- Return type:
- picop.containers.dict_len(d)#
Return
len(d)viaPyDict_GET_SIZE. :type d:dict:param d:- Return type:
- picop.containers.dict_eq(a, b)#
Return True if typed dicts are equal (identity/size short-circuit + richcompare). :type a:
dict:param a: :type b:dict:param b:- Return type:
- picop.containers.dict_size(d)#
Return
len(d)via checkedPyDict_Size.Notes
Prefer
dict_lenon a typeddicthot path.
- picop.containers.dict_set(d, key, value)#
Set
d[key] = valueviaPyDict_SetItem.Notes
Returns
0on success and-1on error; errors raise. Do not use the status int as a bool.
- picop.containers.dict_del(d, key)#
Delete
d[key]viaPyDict_DelItem.Notes
Returns
0on success and-1on error; errors raise. Do not use the status int as a bool.
- picop.containers.dict_pop(d, key)#
Remove
keyand return its value viaPyDict_Pop.Notes
Missing keys yield
None(same ambiguity as a storedNonevalue).
- picop.containers.dict_setdefault(d, key, default=None)#
Return
d.setdefault(key, default)via borrowedPyDict_SetDefault.Notes
The returned reference is borrowed. Prefer
dict_setdefault_refwhen you need a strong ref.
- picop.containers.dict_update(d, other)#
Update
dfromotherviaPyDict_Update.Notes
Returns
0on success and-1on error; errors raise. Do not use the status int as a bool.
- picop.containers.dict_copy(d)#
Return a shallow copy of
dviaPyDict_Copy. :type d:dict:param d:- Return type:
- picop.containers.list_check(p)#
Return True if
pis alistor subtype (PyList_Check). :type p:object:param p:- Return type:
- picop.containers.list_check_exact(p)#
Return True if
type(p) is list(PyList_CheckExact). :type p:object:param p:- Return type:
- picop.containers.deque_eq(a, b)#
Return True if deques are equal.
Notes
Identity short-circuit plus richcompare — same semantics as
deque.__eq__.
- picop.containers.range_eq(a, b)#
Return True if ranges represent the same sequence.
Notes
Identity short-circuit plus richcompare — same semantics as
range.__eq__.
- picop.containers.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:
- picop.containers.list_len(l)#
Return
len(l)viaPyList_GET_SIZE. :type l:list:param l:- Return type:
- picop.containers.list_size(l)#
Return
len(l)via checkedPyList_Size.Notes
Prefer
list_lenon a typedlisthot path.
- picop.containers.list_get(l, i)#
Return
l[i]viaPyList_GET_ITEM.Notes
Unchecked: out-of-bounds is undefined behavior. Prefer
list_get_checked/list_get_refwhen the index may be OOB, or bound the index yourself before calling.
- picop.containers.list_get_checked(l, i)#
Return
l[i]via bounds-checkedPyList_GetItem.Notes
Raises
IndexErroron out-of-bounds (unlike uncheckedlist_get).
- picop.containers.list_get_ref(l, i)#
Return a strong ref to
l[i]viaPyList_GetItemRef.Notes
Raises
IndexErroron out-of-bounds (unlike uncheckedlist_get).
- picop.containers.list_append(l, value)#
Append
valueviaPyList_Append.Notes
Returns
0on success and-1on error; errors raise. Do not use the status int as a bool.
- picop.containers.list_insert(l, i, value)#
Insert
valueativiaPyList_Insert.Notes
Returns
0on success and-1on error; errors raise. Do not use the status int as a bool.
- picop.containers.list_extend(l, iterable)#
Extend
lfromiterableviaPyList_Extend.Notes
Returns
0on success and-1on error; errors raise. Do not use the status int as a bool.
- picop.containers.list_clear(l)#
Clear
lviaPyList_Clear.Notes
Returns
0on success and-1on error; errors raise. Do not use the status int as a bool.
- picop.containers.set_check(p)#
Return True if
pis asetor subtype (PySet_Check). :type p:object:param p:- Return type:
- picop.containers.set_check_exact(p)#
Return True if
type(p) is set(PySet_CheckExact). :type p:object:param p:- Return type:
- picop.containers.frozenset_check(p)#
Return True if
pis afrozensetor subtype. :type p:object:param p:- Return type:
- picop.containers.frozenset_check_exact(p)#
Return True if
type(p) is frozenset. :type p:object:param p:- Return type:
- picop.containers.frozenset_eq(a, b)#
Return True if typed frozensets are equal (identity/size short-circuit + richcompare). :type a:
frozenset:param a: :type b:frozenset:param b:- Return type:
- picop.containers.set_contains(anyset, value)#
Return whether
valueis inanysetviaPySet_Contains. :type anyset:object:param anyset: :type value:object:param value:- Return type:
- picop.containers.set_add(s, value)#
Add
valueviaPySet_Add.Notes
Returns
0on success; errors raise. Do not use the status int as a bool.
- picop.containers.set_discard(s, value)#
Discard
valueviaPySet_Discard.Notes
Returns
1if removed,0if absent (noKeyError). Errors raise. Do not treat the status int as a plain bool for success/failure.
- picop.containers.set_clear(s)#
Clear
sviaPySet_Clear.Notes
Returns
0on success; errors raise. Do not use the status int as a bool.
- picop.containers.set_update(s, iterable)#
Update
sfromiterablevia_PySet_Update.Notes
Returns
0on success; errors raise. Do not use the status int as a bool.
- picop.containers.set_len(s)#
Return
len(s)viaPySet_GET_SIZE(exactset). :type s:set:param s:- Return type:
- picop.containers.set_eq(a, b)#
Return True if typed sets are equal (identity/size short-circuit + richcompare). :type a:
set:param a: :type b:set:param b:- Return type:
- picop.containers.set_size(anyset)#
Return
len(anyset)via checkedPySet_Size.Notes
Accepts set/frozenset/subtypes. Prefer
set_lenon a typed exactsethot path.
- picop.containers.tuple_check(p)#
Return True if
pis atupleor subtype (PyTuple_Check). :type p:object:param p:- Return type:
- picop.containers.tuple_check_exact(p)#
Return True if
type(p) is tuple(PyTuple_CheckExact). :type p:object:param p:- Return type:
- picop.containers.tuple_eq(a, b)#
Return True if typed tuples are equal (identity/len + richcompare). :type a:
tuple:param a: :type b:tuple:param b:- Return type:
- picop.containers.tuple_len(t)#
Return
len(t)viaPyTuple_GET_SIZE. :type t:tuple[object,...] :param t:- Return type:
- picop.containers.tuple_size(t)#
Return
len(t)via checkedPyTuple_Size.Notes
Prefer
tuple_lenon typed hot paths.
- picop.containers.tuple_get(t, i)#
Return
t[i]viaPyTuple_GET_ITEM.Notes
Unchecked: out-of-bounds is undefined behavior. Prefer
tuple_get_checkedwhen the index may be OOB, or bound the index yourself before calling.
- picop.containers.tuple_get_checked(t, i)#
Return
t[i]via bounds-checkedPyTuple_GetItem.Notes
Raises
IndexErroron out-of-bounds (unlike uncheckedtuple_get).
- picop.containers.tuple_pack2(a, b)#
Return
(a, b)viaPyTuple_Pack. :type a:object:param a: :type b:object:param b: