Objetos Conjunto
****************

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.*

   Esta es una instancia de "PyTypeObject" que representa el tipo
   Python "set".

PyTypeObject PyFrozenSet_Type
    * Part of the Stable ABI.*

   Esta es una instancia de "PyTypeObject" que representa el tipo
   Python "frozenset".

Los siguientes macros de comprobación de tipos funcionan en punteros a
cualquier objeto de Python. Del mismo modo, las funciones del
constructor funcionan con cualquier objeto Python iterable.

int PySet_Check(PyObject *p)

   Retorna verdadero si *p* es un objeto "set" o una instancia de un
   subtipo. Esta función siempre finaliza con éxito.

int PyFrozenSet_Check(PyObject *p)

   Retorna verdadero si *p* es un objeto "frozenset" o una instancia
   de un subtipo. Esta función siempre finaliza con éxito.

int PyAnySet_Check(PyObject *p)

   Retorna verdadero si *p* es un objeto "set", un objeto "frozenset",
   o una instancia de un subtipo. Esta función siempre finaliza con
   éxito.

int PySet_CheckExact(PyObject *p)

   Retorna verdadero si *p* es un objeto "set" pero no una instancia
   de un subtipo. Esta función siempre finaliza con éxito.

   Nuevo en la versión 3.10.

int PyAnySet_CheckExact(PyObject *p)

   Retorna verdadero si *p* es un objeto "set" o un objeto "frozenset"
   pero no una instancia de un subtipo. Esta función siempre finaliza
   con éxito.

int PyFrozenSet_CheckExact(PyObject *p)

   Retorna verdadero si *p* es un objeto "frozenset" pero no una
   instancia de un subtipo. Esta función siempre finaliza con éxito.

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

   Retorna un nuevo "set" que contiene objetos retornados por
   *iterable*. El *iterable* puede ser "NULL" para crear un nuevo
   conjunto vacío. Retorna el nuevo conjunto en caso de éxito o "NULL"
   en caso de error. Lanza "TypeError" si *iterable* no es realmente
   iterable. El constructor también es útil para copiar un conjunto
   ("c=set(s)").

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

   Retorna un nuevo "frozenset" que contiene objetos retornados por
   *iterable*. El *iterable* puede ser "NULL" para crear un nuevo
   conjunto congelado vacío. Retorna el nuevo conjunto en caso de
   éxito o "NULL" en caso de error. Lanza "TypeError" si *iterable* no
   es realmente iterable.

Las siguientes funciones y macros están disponibles para instancias de
"set" o "frozenset" o instancias de sus subtipos.

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

   Retorna la longitud de un objeto "set" o "frozenset". Equivalente a
   "len(anyset)". Lanza un "PyExc_SystemError" si *anyset* no es
   "set", "frozenset", o una instancia de un subtipo.

Py_ssize_t PySet_GET_SIZE(PyObject *anyset)

   Forma macro de "PySet_Size()" sin comprobación de errores.

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

   Retorna "1" si se encuentra, "0" si no se encuentra y "-1" si se
   encuentra un error. A diferencia del método Python
   "__contains__()", esta función no convierte automáticamente
   conjuntos no compartibles en congelados temporales. Lanza un
   "TypeError" si la *key* no se puede compartir. Lanza
   "PyExc_SystemError" si *anyset* no es un "set", "frozenset", o una
   instancia de un subtipo.

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.

Las siguientes funciones están disponibles para instancias de "set" o
sus subtipos, pero no para instancias de "frozenset" o sus subtipos.

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

   Retorna "1" si se encuentra y se elimina, "0" si no se encuentra
   (no se realiza ninguna acción) y "-1" si se encuentra un error. No
   lanza "KeyError" por faltar claves. Lanza un "TypeError" si la
   *key* no se puede compartir. A diferencia del método Python
   "discard()", esta función no convierte automáticamente conjuntos no
   compartibles en congelados temporales. Lanza "PyExc_SystemError" si
   *set* no es una instancia de "set" o su subtipo.

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

   Retorna una nueva referencia a un objeto arbitrario en el *set* y
   elimina el objeto del *set*. Retorna "NULL" en caso de falla. Lanza
   "KeyError" si el conjunto está vacío. Lanza a "SystemError" si
   *set* no es una instancia de "set" o su subtipo.

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

   Vacía un conjunto existente de todos los elementos.
