picop.cysentinel#

Fast sentinel helpers (CPython 3.15+).

picop.cysentinel.sentinel_check(obj)#

Return True if obj is a sentinel.

Notes

The sentinel type cannot be subclassed, so sentinel_check and sentinel_check_exact agree on every value.

Parameters:

obj (object)

Return type:

bool

picop.cysentinel.sentinel_check_exact(obj)#

Return True if obj is exactly a sentinel (subtypes excluded).

Parameters:

obj (object)

Return type:

bool

picop.cysentinel.sentinel_new(name, module=None, repr=None)#

Return a newly created sentinel named name.

Notes

Unlike the builtin sentinel constructor, module and repr default to None rather than being inferred. Embedded NUL characters raise ValueError (the C API is NUL-terminated) and unpaired surrogates raise UnicodeEncodeError. Raises NotImplementedError on 3.14.

Parameters:
Return type:

object

picop.cysentinel.sentinel_type()#

Return the builtin sentinel type.

Notes

Raises NotImplementedError on CPython 3.14. Prefer the check helpers over comparing against this type.

Return type:

object