MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / Str_in

Function Str_in

python/stringzilla.c:1842–1851  ·  view source on GitHub ↗

* @brief Will be called by the `PySequence_Contains` to check presence of a substring. * @return 1 if the string is present, 0 if it is not, -1 in case of error. * @see Docs: https://docs.python.org/3/c-api/sequence.html#c.PySequence_Contains */

Source from the content-addressed store, hash-verified

1840 * @see Docs: https://docs.python.org/3/c-api/sequence.html#c.PySequence_Contains
1841 */
1842static int Str_in(Str *self, PyObject *needle_obj) {
1843
1844 sz_string_view_t needle;
1845 if (!sz_py_export_string_like(needle_obj, &needle.start, &needle.length)) {
1846 wrap_current_exception("Unsupported needle layout");
1847 return -1;
1848 }
1849
1850 return sz_find(self->memory.start, self->memory.length, needle.start, needle.length) != NULL;
1851}
1852
1853/**
1854 * @brief Ensures the Strs is in a tape layout (not fragmented).

Callers

nothing calls this directly

Calls 3

sz_py_export_string_likeFunction · 0.85
wrap_current_exceptionFunction · 0.85
sz_findFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…