집합 객체
*********

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()", and "PyObject_GetIter()") or
the abstract number protocol (including "PyNumber_And()",
"PyNumber_Subtract()", "PyNumber_Or()", "PyNumber_Xor()",
"PyNumber_InPlaceAnd()", "PyNumber_InPlaceSubtract()",
"PyNumber_InPlaceOr()", and "PyNumber_InPlaceXor()").

type PySetObject

   This subtype of "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
    * Part of the Stable ABI.*

   이것은 파이썬 "set" 형을 나타내는 "PyTypeObject"의 인스턴스입니다.

PyTypeObject PyFrozenSet_Type
    * Part of the Stable ABI.*

   이것은 파이썬 "frozenset" 형을 나타내는 "PyTypeObject"의 인스턴스입
   니다.

다음 형 검사 매크로는 모든 파이썬 객체에 대한 포인터에서 작동합니다.
마찬가지로, 생성자 함수는 모든 이터러블 파이썬 객체에서 작동합니다.

int PySet_Check(PyObject *p)

   *p*가 "set" 객체나 서브 형의 인스턴스면 참을 반환합니다. 이 함수는
   항상 성공합니다.

int PyFrozenSet_Check(PyObject *p)

   *p*가 "frozenset" 객체나 서브 형의 인스턴스면 참을 반환합니다. 이
   함수는 항상 성공합니다.

int PyAnySet_Check(PyObject *p)

   *p*가 "set" 객체, "frozenset" 객체 또는 서브 형의 인스턴스면 참을
   반환합니다. 이 함수는 항상 성공합니다.

int PySet_CheckExact(PyObject *p)

   Return true if *p* is a "set" object but not an instance of a
   subtype.  This function always succeeds.

   버전 3.10에 추가.

int PyAnySet_CheckExact(PyObject *p)

   *p*가 "set" 객체나 "frozenset" 객체이지만, 서브 형의 인스턴스는 아
   니면 참을 반환합니다. 이 함수는 항상 성공합니다.

int PyFrozenSet_CheckExact(PyObject *p)

   *p*가 "frozenset" 객체이지만, 서브 형의 인스턴스는 아니면 참을 반환
   합니다. 이 함수는 항상 성공합니다.

PyObject *PySet_New(PyObject *iterable)
    *Return value: New reference.** Part of the Stable ABI.*

   *iterable*에 의해 반환된 객체를 포함하는 새로운 "set"을 반환합니다.
   *iterable*은 새로운 빈 집합을 만들기 위해 "NULL" 일 수 있습니다. 성
   공하면 새 집합을, 실패하면 "NULL"을 반환합니다. *iterable*이 실제로
   이터러블이 아니면 "TypeError"를 발생시킵니다. 생성자는 집합을 복사
   할 때도 유용합니다 ("c=set(s)").

PyObject *PyFrozenSet_New(PyObject *iterable)
    *Return value: New reference.** Part of the Stable ABI.*

   *iterable*에 의해 반환된 객체를 포함한 새로운 "frozenset"을 반환합
   니다. *iterable*은 새로운 빈 frozenset을 만들기 위해 "NULL" 일 수
   있습니다. 성공하면 새 집합을, 실패하면 "NULL"을 반환합니다.
   *iterable*이 실제로 이터러블이 아니면 "TypeError"를 발생시킵니다.

"set" 이나 "frozenset"의 인스턴스 또는 그들의 서브 형의 인스턴스에 대
해 다음 함수와 매크로를 사용할 수 있습니다.

Py_ssize_t PySet_Size(PyObject *anyset)
    * Part of the Stable ABI.*

   Return the length of a "set" or "frozenset" object. Equivalent to
   "len(anyset)".  Raises a "SystemError" if *anyset* is not a "set",
   "frozenset", or an instance of a subtype.

Py_ssize_t PySet_GET_SIZE(PyObject *anyset)

   에러 검사 없는 "PySet_Size()"의 매크로 형식.

int PySet_Contains(PyObject *anyset, PyObject *key)
    * Part of the Stable ABI.*

   Return "1" if found, "0" if not found, and "-1" if an error is
   encountered.  Unlike the Python "__contains__()" method, this
   function does not automatically convert unhashable sets into
   temporary frozensets.  Raise a "TypeError" if the *key* is
   unhashable. Raise "SystemError" if *anyset* is not a "set",
   "frozenset", or an instance of a subtype.

int PySet_Add(PyObject *set, PyObject *key)
    * Part of the Stable ABI.*

   Add *key* to a "set" instance.  Also works with "frozenset"
   instances (like "PyTuple_SetItem()" it can be used to fill in the
   values of brand new frozensets before they are exposed to other
   code).  Return "0" on success or "-1" on failure. Raise a
   "TypeError" if the *key* is unhashable. Raise a "MemoryError" if
   there is no room to grow.  Raise a "SystemError" if *set* is not an
   instance of "set" or its subtype.

다음 함수는 "set" 이나 그것의 서브 형의 인스턴스에는 사용할 수 있지만,
"frozenset" 이나 그 서브 형의 인스턴스에는 사용할 수 없습니다.

int PySet_Discard(PyObject *set, PyObject *key)
    * Part of the Stable ABI.*

   Return "1" if found and removed, "0" if not found (no action
   taken), and "-1" if an error is encountered.  Does not raise
   "KeyError" for missing keys.  Raise a "TypeError" if the *key* is
   unhashable.  Unlike the Python "discard()" method, this function
   does not automatically convert unhashable sets into temporary
   frozensets. Raise "SystemError" if *set* is not an instance of
   "set" or its subtype.

PyObject *PySet_Pop(PyObject *set)
    *Return value: New reference.** Part of the Stable ABI.*

   *set*에 들어있는 임의의 객체에 대한 새 참조를 반환하고, *set*에서
   객체를 제거합니다. 실패하면 "NULL"을 반환합니다. 집합이 비어 있으면
   , "KeyError"를 발생시킵니다. *set*이 "set" 이나 그 서브 형의 인스턴
   스가 아니면 "SystemError"를 발생시킵니다.

int PySet_Clear(PyObject *set)
    * Part of the Stable ABI.*

   Empty an existing set of all elements. Return "0" on success.
   Return "-1" and raise "SystemError" if *set* is not an instance of
   "set" or its subtype.
