picop.cydict#
Fast dict accessors.
- picop.cydict.dict_check(p)#
Return True if
pis adictor subtype (PyDict_Check). :type p:object:param p:
- picop.cydict.dict_check_exact(p)#
Return True if
type(p) is dict(PyDict_CheckExact). :type p:object:param p:
- picop.cydict.dict_contains(d, key)#
Return whether
keyis ind(PyDict_Contains). :type d:dict:param d: :type key:str:param key:
- picop.cydict.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.cydict.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:
- picop.cydict.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.cydict.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.cydict.dict_get_with_error(d, key)#
Return
d[key]viaPyDict_GetItemWithError.Notes
Hash/equality errors propagate. Missing keys yield
None(same missing-vs-stored-Noneambiguity asdict_get).
- picop.cydict.dict_merge(d, other, override=True)#
Merge
otherintodviaPyDict_Merge.Notes
overridecontrols whether existing keys are overwritten. Returns0on success and-1on error; errors raise. Do not use the status int as a bool.
- picop.cydict.dict_merge_from_seq2(d, seq2, override=True)#
Merge key/value pairs from
seq2viaPyDict_MergeFromSeq2.Notes
Returns
0on success and-1on error; errors raise. Do not use the status int as a bool.
- picop.cydict.dict_pop(d, key)#
Remove
keyand return its value viaPyDict_Pop.Notes
Missing keys yield
None(same ambiguity as a storedNonevalue).
- picop.cydict.dict_proxy(d)#
Return a read-only
mappingproxyoverd(PyDictProxy_New). :type d:dict:param d:- Return type:
- picop.cydict.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.cydict.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.cydict.dict_setdefault_ref(d, key, default=None)#
Return
setdefaultvia strong-refPyDict_SetDefaultRef. :type d:dict:param d: :type key:object:param key: :type default:object, default:None:param default:- Return type:
- picop.cydict.dict_size(d)#
Return
len(d)via checkedPyDict_Size.Notes
Prefer
dict_lenon a typeddicthot path.