集对象

This section details the public API for set and frozenset objects. Any functionality not listed below is best accessed using either the abstract object protocol (including PyObject_CallMethod() , PyObject_RichCompareBool() , PyObject_Hash() , PyObject_Repr() , PyObject_IsTrue() , PyObject_Print() ,和 PyObject_GetIter() ) or the abstract number protocol (including PyNumber_And() , PyNumber_Subtract() , PyNumber_Or() , PyNumber_Xor() , PyNumber_InPlaceAnd() , PyNumber_InPlaceSubtract() , PyNumber_InPlaceOr() ,和 PyNumber_InPlaceXor() ).

type PySetObject

此子类型的 PyObject is used to hold the internal data for both set and frozenset objects. It is like a PyDictObject in that it is a fixed size for small sets (much like tuple storage) and will point to a separate, variable sized block of memory for medium and large sized sets (much like list storage). None of the fields of this structure should be considered public and all are subject to change. All access should be done through the documented API rather than by manipulating the values in the structure.

PyTypeObject PySet_Type
属于 稳定 ABI (应用程序二进制接口) .

This is an instance of PyTypeObject representing the Python set 类型。

PyTypeObject PyFrozenSet_Type
属于 稳定 ABI (应用程序二进制接口) .

This is an instance of PyTypeObject representing the Python frozenset 类型。

The following type check macros work on pointers to any Python object. Likewise, the constructor functions work with any iterable Python object.

int PySet_Check ( PyObject * p )

返回 True 若 p set object or an instance of a subtype. This function always succeeds.

int PyFrozenSet_Check ( PyObject * p )

返回 True 若 p frozenset object or an instance of a subtype. This function always succeeds.

int PyAnySet_Check ( PyObject * p )

返回 True 若 p set 对象, frozenset object, or an instance of a subtype. This function always succeeds.

int PySet_CheckExact ( PyObject * p )

返回 True 若 p set object but not an instance of a subtype. This function always succeeds.

3.10 版添加。