Mapping Protocol

intPyMapping_Check(PyObject *o)

Return1 if the object provides mapping protocol, and0 otherwise. Thisfunction always succeeds.

Py_ssize_tPyMapping_Size(PyObject *o)
Py_ssize_tPyMapping_Length(PyObject *o)

Returns the number of keys in objecto on success, and-1 on failure. Forobjects that do not provide mapping protocol, this is equivalent to the Pythonexpressionlen(o).

intPyMapping_DelItemString(PyObject *o, const char *key)

Remove the mapping for objectkey from the objecto. Return-1 onfailure. This is equivalent to the Python statementdelo[key].

intPyMapping_DelItem(PyObject *o,PyObject *key)

Remove the mapping for objectkey from the objecto. Return-1 onfailure. This is equivalent to the Python statementdelo[key].

intPyMapping_HasKeyString(PyObject *o, const char *key)

On success, return1 if the mapping object has the keykey and0otherwise. This is equivalent to the Python expressionkeyino.This function always succeeds.

intPyMapping_HasKey(PyObject *o,PyObject *key)

Return1 if the mapping object has the keykey and0 otherwise. Thisis equivalent to the Python expressionkeyino. This function alwayssucceeds.

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

On success, return a list or tuple of the keys in objecto. On failure,returnNULL.

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

On success, return a list or tuple of the values in objecto. On failure,returnNULL.

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

On success, return a list or tuple of the items in objecto, where each itemis a tuple containing a key-value pair. On failure, returnNULL.

PyObject*PyMapping_GetItemString(PyObject *o, const char *key)
Return value: New reference.

Return element ofo corresponding to the objectkey orNULL on failure.This is the equivalent of the Python expressiono[key].

intPyMapping_SetItemString(PyObject *o, const char *key,PyObject *v)

Map the objectkey to the valuev in objecto. Returns-1 on failure.This is the equivalent of the Python statemento[key]=v.