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

Function Str_like_bytesum

python/stringzilla.c:1540–1560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1538 " TypeError: If the argument is not string-like or incorrect number of arguments is provided.";
1539
1540static PyObject *Str_like_bytesum(PyObject *self, PyObject *const *args, Py_ssize_t positional_args_count,
1541 PyObject *args_names_tuple) {
1542 // Check minimum arguments
1543 int is_member = self != NULL && PyObject_TypeCheck(self, &StrType);
1544 if (positional_args_count < !is_member || positional_args_count > !is_member + 1 || args_names_tuple) {
1545 PyErr_SetString(PyExc_TypeError, "bytesum() expects exactly one positional argument");
1546 return NULL;
1547 }
1548
1549 PyObject *text_obj = is_member ? self : args[0];
1550 sz_string_view_t text;
1551
1552 // Validate and convert `text`
1553 if (!sz_py_export_string_like(text_obj, &text.start, &text.length)) {
1554 wrap_current_exception("The text argument must be string-like");
1555 return NULL;
1556 }
1557
1558 sz_u64_t result = sz_bytesum(text.start, text.length);
1559 return PyLong_FromUnsignedLongLong((unsigned long long)result);
1560}
1561
1562static char const doc_like_sha256[] = //
1563 "Compute SHA256 cryptographic hash of the input data.\n"

Callers

nothing calls this directly

Calls 3

sz_py_export_string_likeFunction · 0.85
wrap_current_exceptionFunction · 0.85
sz_bytesumFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…