picop.cyset#

Fast set accessors.

picop.cyset.frozenset_check(p)#

Return True if p is a frozenset or subtype.

Parameters:

p (object)

Return type:

bool

picop.cyset.frozenset_check_exact(p)#

Return True if type(p) is frozenset.

Parameters:

p (object)

Return type:

bool

picop.cyset.frozenset_empty()#

Return a new empty frozenset via PyFrozenSet_New(NULL).

Return type:

frozenset

picop.cyset.frozenset_eq(a, b)#

Return True if typed frozensets are equal (identity/size short-circuit + richcompare).

Parameters:
Return type:

bool

picop.cyset.frozenset_new(iterable)#

Return a new frozenset from iterable via PyFrozenSet_New.

Parameters:

iterable (object)

Return type:

frozenset

picop.cyset.set_add(s, value)#

Add value via PySet_Add.

Notes

Slower than the plain-Python equivalent s.add(v) (Tier A 1.07x); unchecked set mutation.

Returns 0 on success; errors raise. Do not use the status int as a bool.

Parameters:
Return type:

int

picop.cyset.set_any_check(p)#

Return True if p is a set or frozenset (or subtype).

Parameters:

p (object)

Return type:

bool

picop.cyset.set_any_check_exact(p)#

Return True if type(p) is set or frozenset (no subtype).

Parameters:

p (object)

Return type:

bool

picop.cyset.set_check(p)#

Return True if p is a set or subtype (PySet_Check).

Parameters:

p (object)

Return type:

bool

picop.cyset.set_check_exact(p)#

Return True if type(p) is set (PySet_CheckExact).

Parameters:

p (object)

Return type:

bool

picop.cyset.set_clear(s)#

Clear s via PySet_Clear.

Notes

Slower than the plain-Python equivalent s.clear() (Tier A 1.03x); unchecked set mutation.

Returns 0 on success; errors raise. Do not use the status int as a bool.

Parameters:

s (set)

Return type:

int

picop.cyset.set_contains(anyset, value)#

Return whether value is in anyset via PySet_Contains.

Parameters:
Return type:

bool

picop.cyset.set_copy(s)#

Shallow-copy s via PySet_New(s).

Parameters:

s (set)

Return type:

set

picop.cyset.set_discard(s, value)#

Discard value via PySet_Discard.

Notes

Slower than the plain-Python equivalent s.discard(v) (Tier A 1.04–1.06x); unchecked set mutation.

Returns 1 if removed, 0 if absent (no KeyError). Errors raise. Do not treat the status int as a plain bool for success/failure.

Parameters:
Return type:

int

picop.cyset.set_empty()#

Return a new empty set via PySet_New(NULL).

Return type:

set

picop.cyset.set_eq(a, b)#

Return True if typed sets are equal (identity/size short-circuit + richcompare).

Parameters:
Return type:

bool

picop.cyset.set_len(s)#

Return len(s) via PySet_GET_SIZE (exact set).

Parameters:

s (set)

Return type:

int

picop.cyset.set_new(iterable)#

Return a new set from iterable via PySet_New.

Parameters:

iterable (object)

Return type:

set

picop.cyset.set_pop(s)#

Return and remove an arbitrary element of s (PySet_Pop).

Notes

Slower than the plain-Python equivalent s.pop() (Tier A 1.08x); unchecked set mutation.

Parameters:

s (set)

Return type:

object

picop.cyset.set_size(anyset)#

Return len(anyset) via checked PySet_Size.

Notes

Accepts set/frozenset/subtypes. Prefer set_len on a typed exact set hot path.

Parameters:

anyset (object)

Return type:

int

picop.cyset.set_update(s, iterable)#

Update s from iterable via _PySet_Update.

Notes

Slower than the plain-Python equivalent s.update(it) (Tier A 1.07x); unchecked set mutation.

Returns 0 on success; errors raise. Do not use the status int as a bool.

Parameters:
Return type:

int