picop.containers#
Category facade: typed Core containers (dict / frozendict / 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_exact(p)#
Return True if
type(p) is dict(PyDict_CheckExact).
- 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).
- picop.containers.dict_len(d)#
Return
len(d)viaPyDict_GET_SIZE.
- picop.containers.dict_eq(a, b)#
Return True if typed dicts are equal (identity/size short-circuit + richcompare).
- 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.
- picop.containers.frozendict_check(obj)#
Return True if
objis a frozendict or a frozendict subtype.
- picop.containers.frozendict_check_exact(obj)#
Return True if
objis exactly a frozendict (subtypes excluded).
- picop.containers.frozendict_empty()#
Return an empty frozendict without building an iterable.
Notes
raises
NotImplementedErroron 3.14.- Return type:
- picop.containers.frozendict_new(iterable)#
Return a new frozendict built from an iterable.
Notes
Noneis not iterable — usefrozendict_empty()for the no-iterable path. Passing an existing frozendict returns the same object with an incremented reference, not a copy. RaisesNotImplementedErroron 3.14.
- picop.containers.anydict_check(obj)#
Return True if
objis a dict or a frozendict (subtypes included).Notes
mirrors
PyAnyDict_Check; on 3.14 this isdict_check.
- picop.containers.anydict_check_exact(obj)#
Return True if
objis exactly a dict or exactly a frozendict.Notes
dictsubclasses such asdefaultdictare False.
- picop.containers.anydict_len(obj)#
Return the entry count of a dict or frozendict.
Notes
raises
TypeErrorfor anything else; the read uses thePyDict_GET_SIZElayout shared by dict and frozendict.
- picop.containers.list_check_exact(p)#
Return True if
type(p) is list(PyList_CheckExact).
- 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).
- picop.containers.list_len(l)#
Return
len(l)viaPyList_GET_SIZE.
- 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_exact(p)#
Return True if
type(p) is set(PySet_CheckExact).
- picop.containers.frozenset_check_exact(p)#
Return True if
type(p) is frozenset.
- picop.containers.frozenset_eq(a, b)#
Return True if typed frozensets are equal (identity/size short-circuit + richcompare).
- picop.containers.set_contains(anyset, value)#
Return whether
valueis inanysetviaPySet_Contains.
- picop.containers.set_add(s, value)#
Add
valueviaPySet_Add.Notes
Slower than the plain-Python equivalent
s.add(v)(Tier A 1.07x); unchecked set mutation.Returns
0on success; errors raise. Do not use the status int as a bool.
- picop.containers.set_discard(s, value)#
Discard
valueviaPySet_Discard.Notes
Slower than the plain-Python equivalent
s.discard(v)(Tier A 1.04–1.06x); unchecked set mutation.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
Slower than the plain-Python equivalent
s.clear()(Tier A 1.03x); unchecked set mutation.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
Slower than the plain-Python equivalent
s.update(it)(Tier A 1.07x); unchecked set mutation.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).
- picop.containers.set_eq(a, b)#
Return True if typed sets are equal (identity/size short-circuit + richcompare).
- 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_exact(p)#
Return True if
type(p) is tuple(PyTuple_CheckExact).
- picop.containers.tuple_eq(a, b)#
Return True if typed tuples are equal (identity/len + richcompare).
- picop.containers.tuple_len(t)#
Return
len(t)viaPyTuple_GET_SIZE.
- 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.
- picop.containers.tuple_pack3(a, b, c)#
Return
(a, b, c)viaPyTuple_Pack.