(object protocol)

PyObject* Py_NotImplemented

(NotImplemented)

Py_RETURN_NOTIMPLEMENTED

C Py_NotImplemented ( NotImplemented )

int PyObject_Print(PyObject *o, FILE *fp, int flags)

o fp -1 flags Py_PRINT_RAW ; repr() str()

int PyObject_HasAttr(PyObject *o, PyObject *attr_name)

o attr_name 1 0 Python hasattr(o, attr_name)

int PyObject_HasAttrString(PyObject *o, const char *attr_name)

o attr_name 1 0 Python hasattr(o, attr_name)

PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name)
Return value: New reference.

o attr_name NULL Python o.attr_name

PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name)
Return value: New reference.

o attr_name NULL Python o.attr_name

PyObject* PyObject_GenericGetAttr(PyObject *o, PyObject *name)

tp_getattro () __dict__ MRO (descriptor) AttributeError

int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v)

o attr_name v -1 ; 0 Python o.attr_name = v

v NULL PyObject_DelAttr()

int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v)

o attr_name v -1 ; 0 Python o.attr_name = v

v NULL PyObject_DelAttrString()

int PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value)

tp_setattro MRO () __dict__ 0 AttributeError -1

int PyObject_DelAttr(PyObject *o, PyObject *attr_name)

o attr_name -1 Python del o.attr_name

int PyObject_DelAttrString(PyObject *o, const char *attr_name)

o attr_name -1 Python del o.attr_name

PyObject* PyObject_GenericGetDict(PyObject *o, void *context)

__dict__ getter

3.3 .

int PyObject_GenericSetDict(PyObject *o, void *context)

__dict__ setter

3.3 .

PyObject* PyObject_RichCompare(PyObject *o1, PyObject *o2, int opid)
Return value: New reference.

o1 o2 opid opid Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE, <, <=, ==, !=, >, >= Python o1 op o2 op opid NULL

int PyObject_RichCompareBool(PyObject *o1, PyObject *o2, int opid)

o1 o2 opid opid Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE, <, <=, ==, !=, >, >= 1 0 -1 Python o1 op o2 op opid

o1 o2 PyObject_RichCompareBool() Py_EQ 1 Py_NE 0

PyObject* PyObject_Repr(PyObject *o)
Return value: New reference.

o NULL Python repr(o) repr()

3.4 :

PyObject* PyObject_ASCII(PyObject *o)

PyObject_Repr() o PyObject_Repr() ASCII \x \u \U Pythoh 2 PyObject_Repr() ascii()

PyObject* PyObject_Str(PyObject *o)
Return value: New reference.

o NULL Python str(o) str() print()

3.4 :

PyObject* PyObject_Bytes(PyObject *o)

o NULL bytes o Python bytes(o) bytes(o) o bytes TypeError

int PyObject_IsSubclass(PyObject *derived, PyObject *cls)

derived cls 1 0 -1

cls cls 1 1 1 0

cls __subclasscheck__() PEP 3119 derived cls cls.__mro__

type __bases__ ()

int PyObject_IsInstance(PyObject *inst, PyObject *cls)

inst cls cls 1 0 -1

cls cls 1 1 1 0

cls __instancecheck__() PEP 3119 inst cls cls

inst __class__

cls __bases__ ()

int PyCallable_Check(PyObject *o)

o 1 0

PyObject* PyObject_Call(PyObject *callable_object, PyObject *args, PyObject *kw)
Return value: New reference.

Python callable_object args (named argument) kw kw NULL args NULL NULL Python callable_object(*args, **kw)

PyObject* PyObject_CallObject(PyObject *callable_object, PyObject *args)
Return value: New reference.

Python callable_object args args NULL NULL Python callable_object(*args)

PyObject* PyObject_CallFunction(PyObject *callable, const char *format, ...)
Return value: New reference.

Python callable C C Py_BuildValue() format NULL NULL Python callable(*args) PyObject * args PyObject_CallFunctionObjArgs()

3.4 : format char *

PyObject* PyObject_CallMethod(PyObject *o, const char *method, const char *format, ...)
Return value: New reference.

o method C C Py_BuildValue() format NULL NULL Python o.method(args) PyObject * args PyObject_CallMethodObjArgs()

3.4 : method format char *

PyObject* PyObject_CallFunctionObjArgs(PyObject *callable, ..., NULL)
Return value: New reference.

Python callable PyObject* NULL NULL

PyObject* PyObject_CallMethodObjArgs(PyObject *o, PyObject *name, ..., NULL)
Return value: New reference.

o Python name PyObject* . NULL NULL

Py_hash_t PyObject_Hash(PyObject *o)

o -1 Python hash(o)

3.2 : Py_hash_t Py_ssize_t

Py_hash_t PyObject_HashNotImplemented(PyObject *o)

type(o) TypeError -1 tp_hash type

int PyObject_IsTrue(PyObject *o)

o 1 0 Python not not o -1

int PyObject_Not(PyObject *o)

o 0 1 Python not o -1

PyObject* PyObject_Type(PyObject *o)
Return value: New reference.

o NULL o SystemError NULL Python type(o) PyTypeObject* o->ob_type

int PyObject_TypeCheck(PyObject *o, PyTypeObject *type)

o type type NULL

Py_ssize_t PyObject_Length(PyObject *o)
Py_ssize_t PyObject_Size(PyObject *o)

o o -1 Python len(o)

Py_ssize_t PyObject_LengthHint(PyObject *o, Py_ssize_t default)

o __length_hint__() Python operator.length_hint(o, default)

3.4 .

PyObject* PyObject_GetItem(PyObject *o, PyObject *key)
Return value: New reference.

key o NULL Python o[key]

int PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v)

key v -1 ; 0 Python o[key] = v

int PyObject_DelItem(PyObject *o, PyObject *key)

Delete the mapping for key from o. Returns -1 on failure. This is the equivalent of the Python statement del o[key].

PyObject* PyObject_Dir(PyObject *o)
Return value: New reference.

Python dir(o) () NULL NULL Python dir() ; NULL PyErr_Occurred()

PyObject* PyObject_GetIter(PyObject *o)
Return value: New reference.

Python iter(o) TypeError NULL