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

Function Str_like_equal

python/stringzilla.c:1732–1756  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1730 " TypeError: If the argument is not string-like or incorrect number of arguments is provided.";
1731
1732static PyObject *Str_like_equal(PyObject *self, PyObject *const *args, Py_ssize_t positional_args_count,
1733 PyObject *args_names_tuple) {
1734 // Check minimum arguments
1735 int is_member = self != NULL && PyObject_TypeCheck(self, &StrType);
1736 if (positional_args_count < !is_member || positional_args_count > !is_member + 1 || args_names_tuple) {
1737 PyErr_SetString(PyExc_TypeError, "equals() expects exactly two positional arguments");
1738 return NULL;
1739 }
1740
1741 PyObject *text_obj = is_member ? self : args[0];
1742 PyObject *other_obj = args[is_member];
1743 sz_string_view_t text, other;
1744
1745 // Validate and convert tje texts
1746 if (!sz_py_export_string_like(text_obj, &text.start, &text.length) || //
1747 !sz_py_export_string_like(other_obj, &other.start, &other.length)) {
1748 wrap_current_exception("The arguments must be string-like");
1749 return NULL;
1750 }
1751
1752 if (text.length != other.length) { Py_RETURN_FALSE; }
1753 sz_bool_t result = sz_equal(text.start, other.start, text.length);
1754 if (result != sz_true_k) { Py_RETURN_FALSE; }
1755 Py_RETURN_TRUE;
1756}
1757
1758static PyObject *Str_get_address(Str *self, void *closure) { return PyLong_FromSize_t((sz_size_t)self->memory.start); }
1759static PyObject *Str_get_nbytes(Str *self, void *closure) { return PyLong_FromSize_t(self->memory.length); }

Callers

nothing calls this directly

Calls 3

sz_py_export_string_likeFunction · 0.85
wrap_current_exceptionFunction · 0.85
sz_equalFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…