picop.cystr#
Fast str accessors.
- picop.cystr.find(s, sub)#
- picop.cystr.is_ascii(s)#
- picop.cystr.str_all_alnum_ascii(s)#
Return True if
sis non-empty and every code unit is ASCII alnum. :type s:str:param s:- Return type:
- picop.cystr.str_all_alpha_ascii(s)#
Return True if
sis non-empty and every code unit is ASCIIA-Za-z. :type s:str:param s:- Return type:
- picop.cystr.str_all_digits(s)#
Return True if
sis non-empty and every code unit is ASCII0-9. :type s:str:param s:- Return type:
- picop.cystr.str_as_or_empty(obj)#
Return
objif it is an exactstr, else"". :type obj:object:param obj:- Return type:
- picop.cystr.str_char_at(s, i)#
Return the code point at
iviaPyUnicode_READ.Notes
Unchecked: out-of-bounds is undefined behavior. Bound the index yourself before calling.
- picop.cystr.str_check(obj)#
Return True if
objis astror subtype (PyUnicode_Check). :type obj:object:param obj:- Return type:
- picop.cystr.str_check_exact(obj)#
Return True if
type(obj) is str(PyUnicode_CheckExact).Notes
Prefer over
str_is/is_str/ucheck_exactin check-pair tables (N3).
- picop.cystr.str_cmp(a, b)#
Three-way compare of typed
strvalues viaPyUnicode_Compare.Notes
Returns
-1/0/1for less / equal / greater.
- picop.cystr.str_concat(a, b)#
Return
a + bviaPyUnicode_Concat. :type a:str:param a: :type b:str:param b:- Return type:
- picop.cystr.str_concat3(a, b, c)#
Return
a + b + cvia twoPyUnicode_Concatcalls. :type a:str:param a: :type b:str:param b: :type c:str:param c:- Return type:
- picop.cystr.str_concat4(a, b, c, d)#
Return
a + b + c + dvia threePyUnicode_Concatcalls. :type a:str:param a: :type b:str:param b: :type c:str:param c: :type d:str:param d:- Return type:
- picop.cystr.str_contains(haystack, needle)#
Return whether
needleis inhaystack.Notes
Uses 1BYTE
memchr/memmemorFinddepending on kind.
- picop.cystr.str_endswith(s, suffix)#
Return whether
sends withsuffix.Notes
Uses 1BYTE
memcmpor Tailmatch depending on kind.
- picop.cystr.str_eq(a, b)#
Return whether
a == b.Notes
Uses 1BYTE
memcmporPyUnicode_Comparedepending on kind.
- picop.cystr.str_find(s, sub)#
- picop.cystr.str_first_char(s)#
Return the first code point via
PyUnicode_READ.Notes
Unchecked: an empty string is undefined behavior.
- picop.cystr.str_ge(a, b)#
Return True if typed
a >= b(viastr_cmp). :type a:str:param a: :type b:str:param b:- Return type:
- picop.cystr.str_gt(a, b)#
Return True if typed
a > b(viastr_cmp). :type a:str:param a: :type b:str:param b:- Return type:
- picop.cystr.str_is(obj)#
Return True if
type(obj) is str.Notes
Same gate as
str_check_exact(N3); alias ofis_str.
- picop.cystr.str_is_ascii(s)#
- picop.cystr.str_is_blank(s)#
Return True if every code unit is ASCII whitespace (space/tab/LF/VT/FF/CR). :type s:
str:param s:- Return type:
- picop.cystr.str_is_not(obj)#
Return True if
type(obj) is not str. :type obj:object:param obj:- Return type:
- picop.cystr.str_last_char(s)#
Return the last code point via
PyUnicode_READ.Notes
Unchecked: an empty string is undefined behavior.
- picop.cystr.str_le(a, b)#
Return True if typed
a <= b(viastr_cmp). :type a:str:param a: :type b:str:param b:- Return type:
- picop.cystr.str_lt(a, b)#
Return True if typed
a < b(viastr_cmp). :type a:str:param a: :type b:str:param b:- Return type:
- picop.cystr.str_ne(a, b)#
Return whether
a != b(negatedstr_eq). :type a:str:param a: :type b:str:param b:- Return type:
- picop.cystr.str_none_to_empty(obj)#
Return
objif exactstr, else"".Notes
Also yields
""whenobj is None.
- picop.cystr.str_not_empty(s)#
Return True if
shas non-zero length. :type s:str:param s:- Return type:
- picop.cystr.str_or_empty(obj)#
Return
objif truthy exactstr, else"". :type obj:object:param obj:- Return type: