MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / Py_HashBuffer

Function Py_HashBuffer

asyncpg/protocol/record/pythoncapi_compat.h:1613–1629  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1611
1612#if PY_VERSION_HEX < 0x030E00A0
1613static inline Py_hash_t Py_HashBuffer(const void *ptr, Py_ssize_t len)
1614{
1615#if PY_VERSION_HEX >= 0x03000000 && !defined(PYPY_VERSION)
1616 PyAPI_FUNC(Py_hash_t) _Py_HashBytes(const void *src, Py_ssize_t len);
1617
1618 return _Py_HashBytes(ptr, len);
1619#else
1620 Py_hash_t hash;
1621 PyObject *bytes = PyBytes_FromStringAndSize((const char*)ptr, len);
1622 if (bytes == NULL) {
1623 return -1;
1624 }
1625 hash = PyObject_Hash(bytes);
1626 Py_DECREF(bytes);
1627 return hash;
1628#endif
1629}
1630#endif
1631
1632

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected