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

Function Str_richcompare

python/stringzilla.c:2212–2229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2210}
2211
2212static PyObject *Str_richcompare(PyObject *self, PyObject *other, int op) {
2213
2214 sz_cptr_t a_start = NULL, b_start = NULL;
2215 sz_size_t a_length = 0, b_length = 0;
2216 if (!sz_py_export_string_like(self, &a_start, &a_length) || !sz_py_export_string_like(other, &b_start, &b_length))
2217 Py_RETURN_NOTIMPLEMENTED;
2218
2219 int order = (int)sz_order(a_start, a_length, b_start, b_length);
2220 switch (op) {
2221 case Py_LT: return PyBool_FromLong(order < 0);
2222 case Py_LE: return PyBool_FromLong(order <= 0);
2223 case Py_EQ: return PyBool_FromLong(order == 0);
2224 case Py_NE: return PyBool_FromLong(order != 0);
2225 case Py_GT: return PyBool_FromLong(order > 0);
2226 case Py_GE: return PyBool_FromLong(order >= 0);
2227 default: Py_RETURN_NOTIMPLEMENTED;
2228 }
2229}
2230
2231static PyObject *Strs_richcompare(PyObject *self, PyObject *other, int op) {
2232

Callers

nothing calls this directly

Calls 2

sz_py_export_string_likeFunction · 0.85
sz_orderFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…