picop.cyobject#
Object protocol helpers.
- picop.cyobject.obj_as_fd(o)#
Return a file descriptor via
PyObject_AsFileDescriptor.Notes
Slower than the plain-Python equivalent
x.fileno()(Tier A 1.40x); last- resort bridge for unknown objects.On error raises — do not treat the result as a boolean success flag.
- picop.cyobject.obj_bytes(o)#
Return
bytes(o)viaPyObject_Bytes.
- picop.cyobject.obj_call(callable_object, args, kw=None)#
Call
callable_object(*args, **kw)viaPyObject_Call.Notes
argsmust be a tuple;kwmust be a dict orNone(no keywords).
- picop.cyobject.obj_call_object(callable_object, args)#
Call
callable_object(*args)viaPyObject_CallObject.
- picop.cyobject.obj_callable(o)#
Return True if
ois callable (PyCallable_Check).
- picop.cyobject.obj_delattr(o, name)#
Delete attribute
nameonoviaPyObject_DelAttr.Notes
Returns
0on success; errors raise — do not use the status as a bool.
- picop.cyobject.obj_delattr_cstr(o, name)#
Delete C-string attribute
nameviaPyObject_DelAttrString.Notes
namemust bebytes, notstr. Returns0on success; errors raise — do not use the status as a bool. Alias ofobj_delattr_string.
- picop.cyobject.obj_delitem(o, key)#
Delete
o[key]viaPyObject_DelItem.Notes
Returns
0on success; errors raise — do not use the status as a bool.
- picop.cyobject.obj_dir(o)#
Return
dir(o)viaPyObject_Dir.
- picop.cyobject.obj_eq(a, b)#
Return True if
a == bviaPyObject_RichCompareBool.Notes
Identity short-circuit applies. Prefer typed
*_eqwhen both operands have a known Core type.
- picop.cyobject.obj_format(obj, format_spec)#
Return
format(obj, format_spec)viaPyObject_Format.Notes
Slower than the plain-Python equivalent
format(x, spec)(Tier A 1.03x); last-resort bridge for unknown objects.
- picop.cyobject.obj_getattr(o, name)#
Return
getattr(o, name)viaPyObject_GetAttr.
- picop.cyobject.obj_getattr_cstr(o, name)#
Return the attribute named by a C string (
PyObject_GetAttrString).
- picop.cyobject.obj_getitem(o, key)#
Return
o[key]viaPyObject_GetItem.Notes
Slower than the plain-Python equivalent
x[key](Tier A 1.03x); last-resort bridge for unknown objects.
- picop.cyobject.obj_hasattr(o, name)#
Return True if
ohas attributename(PyObject_HasAttr).Notes
Slower than the plain-Python equivalent
hasattr(x, name)(Tier A 1.04–1.05x); last-resort bridge for unknown objects.
- picop.cyobject.obj_hasattr_cstr(o, name)#
Return True if
ohas the attribute named by a C string (PyObject_HasAttrString).
- picop.cyobject.obj_hash(o)#
Return the hash of
o(PyObject_Hash).
- picop.cyobject.obj_isinstance(inst, cls)#
Return True if
instis an instance ofcls(PyObject_IsInstance).
- picop.cyobject.obj_issubclass(derived, cls)#
Return
issubclass(derived, cls)viaPyObject_IsSubclass.
- picop.cyobject.obj_istrue(o)#
Return the truthiness of
o(PyObject_IsTrue).Notes
Slower than the plain-Python equivalent
bool(x)(Tier A 1.07–1.07x); last- resort bridge for unknown objects.
- picop.cyobject.obj_iter(o)#
Return
iter(o)viaPyObject_GetIter.
- picop.cyobject.obj_len(o)#
Return
len(o)viaPyObject_Length.
- picop.cyobject.obj_length_hint(o, default_value)#
Return
operator.length_hint(o, default_value)viaPyObject_LengthHint.
- picop.cyobject.obj_repr(o)#
Return
repr(o)viaPyObject_Repr.
- picop.cyobject.obj_richcompare(o1, o2, opid)#
Return rich comparison of
o1ando2foropid(Py_EQ…).
- picop.cyobject.obj_richcompare_bool(o1, o2, opid)#
Return rich comparison as bool for
opid(PyObject_RichCompareBool).
- picop.cyobject.obj_setattr(o, name, v)#
Set attribute
nameonoviaPyObject_SetAttr.Notes
Returns
0on success; errors raise — do not use the status as a bool.
- picop.cyobject.obj_setattr_cstr(o, name, v)#
Set C-string attribute
nameonoviaPyObject_SetAttrString.Notes
namemust bebytes, notstr. Returns0on success; errors raise — do not use the status as a bool. Alias ofobj_setattr_string.
- picop.cyobject.obj_setitem(o, key, v)#
Set
o[key] = vviaPyObject_SetItem.Notes
Returns
0on success; errors raise — do not use the status as a bool.
- picop.cyobject.obj_size(o)#
Return
Py_SIZE-style length viaPyObject_Size(alias ofobj_len).Notes
Slower than the plain-Python equivalent
len(x)(Tier A 1.03x); last-resort bridge for unknown objects.
- picop.cyobject.obj_str(o)#
Return
str(o)viaPyObject_Str.Notes
Slower than the plain-Python equivalent
str(x)(Tier A 1.03x); last-resort bridge for unknown objects.