HPy Dict

int HPyDict_Check(HPyContext *ctx, HPy h)
[source]

Tests if an object is an instance of a Python dict.

Parameters
  • ctx – The execution context.

  • h – A handle to an arbitrary object (must not be HPy_NULL).

Returns

Non-zero if object h is an instance of type dict or an instance of a subtype of dict, and 0 otherwise.

HPy HPyDict_New(HPyContext *ctx)
[source]

Creates a new empty Python dictionary.

Parameters
  • ctx – The execution context.

Returns

A handle to the new and empty Python dictionary or HPy_NULL in case of an error.

HPy HPyDict_Keys(HPyContext *ctx, HPy h)
[source]

Returns a list of all keys from the dictionary.

Note: This function will directly access the storage of the dict object and therefore ignores if method keys was overwritten.

Parameters
  • ctx – The execution context.

  • h – A Python dict object. If this argument is HPy_NULL or not an instance of a Python dict, a SystemError will be raised.

Returns

A Python list object containing all keys of the given dictionary or HPy_NULL in case of an error.

HPy HPyDict_Copy(HPyContext *ctx, HPy h)
[source]

Creates a copy of the provided Python dict object.

Parameters
  • ctx – The execution context.

  • h – A Python dict object. If this argument is HPy_NULL or not an instance of a Python dict, a SystemError will be raised.

Returns

Return a new dictionary that contains the same key-value pairs as h or HPy_NULL in case of an error.