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

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()").

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

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

PyTypeObject PyFrozenSet_Type

   이것은 파이썬 "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 PyAnySet_CheckExact(PyObject *p)

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

int PyFrozenSet_CheckExact(PyObject *p)

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

PyObject* PySet_New(PyObject *iterable)
    *Return value: New reference.*

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

PyObject* PyFrozenSet_New(PyObject *iterable)
    *Return value: New reference.*

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

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

Py_ssize_t PySet_Size(PyObject *anyset)

   "set" 이나 "frozenset" 객체의 길이를 반환합니다. "len(anyset)"와 동
   등합니다. *anyset*이 "set", "frozenset" 또는 서브 형의 인스턴스가
   아니면 "PyExc_SystemError"를 발생시킵니다.

Py_ssize_t PySet_GET_SIZE(PyObject *anyset)

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

int PySet_Contains(PyObject *anyset, PyObject *key)

   발견되면 "1"을, 발견되지 않으면 "0"을, 에러가 발생하면 "-1"을 반환
   합니다. 파이썬 "__contains__()" 메서드와는 달리, 이 함수는 해시 불
   가능한 집합을 임시 frozenset으로 자동 변환하지 않습니다. *key*가 해
   시 불가능하면, "TypeError"를 발생시킵니다. *anyset*이 "set",
   "frozenset" 또는 서브 형의 인스턴스가 아니면 "PyExc_SystemError"를
   발생시킵니다.

int PySet_Add(PyObject *set, PyObject *key)

   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)

   발견되고 제거되면 "1"을 반환하고, 발견되지 않으면(아무런 일도 하지
   않습니다) "0"을 반환하고, 에러가 발생하면 "-1"을 반환합니다. 발견할
   수 없는 키에 대해 "KeyError"를 발생시키지 않습니다. *key*가 해시 불
   가능하면 "TypeError"를 발생시킵니다. 파이썬 "discard()" 메서드와는
   달리, 이 함수는 해시 불가능한 집합을 임시 frozenset으로 자동 변환하
   지 않습니다. *set*이 "set" 이나 그 서브 형의 인스턴스가 아니면
   "PyExc_SystemError"를 발생시킵니다.

PyObject* PySet_Pop(PyObject *set)
    *Return value: New reference.*

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

int PySet_Clear(PyObject *set)

   기존의 모든 요소 집합을 비웁니다.
