Skip to content

Commit

Permalink
Merge branch 'master' into feature/perf_test
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimes committed Jul 21, 2024
2 parents 64c7e45 + aa053e5 commit b14abef
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 72 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ["sphinx.ext.autodoc", "myst_parser"]
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon", "myst_parser"]

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
Expand Down
99 changes: 29 additions & 70 deletions src/mmh3/mmh3module.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,30 +479,19 @@ MMH3Hasher32_get_name(PyObject *self, void *closure)
}

static PyGetSetDef MMH3Hasher32_getsetters[] = {
{"digest_size", (getter)MMH3Hasher32_get_digest_size, NULL, NULL, NULL},
{"block_size", (getter)MMH3Hasher32_get_block_size, NULL, NULL, NULL},
{"name", (getter)MMH3Hasher32_get_name, NULL, NULL, NULL},
{"digest_size", (getter)MMH3Hasher32_get_digest_size, NULL,
"number of bytes in this hashes output", NULL},
{"block_size", (getter)MMH3Hasher32_get_block_size, NULL,
"number of bytes of the internal block of this algorithm", NULL},
{"name", (getter)MMH3Hasher32_get_name, NULL,
"the hash algorithm being used by this object", NULL},
{NULL} /* Sentinel */
};

PyDoc_STRVAR(
MMH3Hasher32Type_doc,
"An mmh3_32 is an object used to calculate the murmurhash3_x86_32 hash\n"
"of a string of information.\n"
"\n"
"Methods:\n"
"\n"
"update(input) -- updates the current digest with an additional string\n"
"digest() -- return the current digest value\n"
"sintdigest() -- return the current digest as a 32 bit signed integer\n"
"uintdigest() -- return the current digest as a 32 bit unsigned integer\n"
"copy() -- return a copy of the current object\n"
"\n"
"Attributes:\n"
"\n"
"name -- the hash algorithm being used by this object\n"
"digest_size -- number of bytes in this hashes output\n"
"block_size -- number of bytes of the internal block of this algorithm");
"of a string of information.");

static PyTypeObject MMH3Hasher32Type = {
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "mmh3.mmh3_32",
Expand Down Expand Up @@ -801,35 +790,19 @@ MMH3Hasher128x64_get_name(PyObject *self, void *closure)
}

static PyGetSetDef MMH3Hasher128x64_getsetters[] = {
{"digest_size", (getter)MMH3Hasher128x64_get_digest_size, NULL, NULL,
NULL},
{"block_size", (getter)MMH3Hasher128x64_get_block_size, NULL, NULL, NULL},
{"name", (getter)MMH3Hasher128x64_get_name, NULL, NULL, NULL},
{"digest_size", (getter)MMH3Hasher128x64_get_digest_size, NULL,
"number of bytes in this hashes output", NULL},
{"block_size", (getter)MMH3Hasher128x64_get_block_size, NULL,
"number of bytes of the internal block of this algorithm", NULL},
{"name", (getter)MMH3Hasher128x64_get_name, NULL,
"the hash algorithm being used by this object", NULL},
{NULL} /* Sentinel */
};

PyDoc_STRVAR(
MMH3Hasher128x64Type_doc,
"An mmh3_x64_128 is an object used to calculate the murmurhash3_x64_128\n"
"hash of a string of information.\n"
"\n"
"Methods:\n"
"\n"
"update(input) -- updates the current digest with an additional string\n"
"digest() -- return the current digest value\n"
"sintdigest() -- return the current digest as a 128 bit signed integer\n"
"uintdigest() -- return the current digest as a 128 bit unsigned integer\n"
"stupledigest() -- return the current digest as a tuple of two 64 bit\n"
" signed integers\n"
"utupledigest() -- return the current digest as a tuple of two 64 bit\n"
" unsigned integers\n"
"copy() -- return a copy of the current object\n"
"\n"
"Attributes:\n"
"\n"
"name -- the hash algorithm being used by this object\n"
"digest_size -- number of bytes in this hashes output\n"
"block_size -- number of bytes of the internal block of this algorithm");
"hash of a string of information.");

static PyTypeObject MMH3Hasher128x64Type = {
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "mmh3.mmh3_x64_128",
Expand Down Expand Up @@ -1126,35 +1099,19 @@ MMH3Hasher128x86_get_name(PyObject *self, void *closure)
}

static PyGetSetDef MMH3Hasher128x86_getsetters[] = {
{"digest_size", (getter)MMH3Hasher128x86_get_digest_size, NULL, NULL,
NULL},
{"block_size", (getter)MMH3Hasher128x86_get_block_size, NULL, NULL, NULL},
{"name", (getter)MMH3Hasher128x86_get_name, NULL, NULL, NULL},
{"digest_size", (getter)MMH3Hasher128x86_get_digest_size, NULL,
"number of bytes in this hashes output", NULL},
{"block_size", (getter)MMH3Hasher128x86_get_block_size, NULL,
"number of bytes of the internal block of this algorithm", NULL},
{"name", (getter)MMH3Hasher128x86_get_name, NULL,
"the hash algorithm being used by this object", NULL},
{NULL} /* Sentinel */
};

PyDoc_STRVAR(
MMH3Hasher128x86Type_doc,
"An mmh3_x86_128 is an object used to calculate the murmurhash3_x86_128\n"
"hash of a string of information.\n"
"\n"
"Methods:\n"
"\n"
"update(input) -- updates the current digest with an additional string\n"
"digest() -- return the current digest value\n"
"sintdigest() -- return the current digest as a 128 bit signed integer\n"
"uintdigest() -- return the current digest as a 128 bit unsigned integer\n"
"stupledigest() -- return the current digest as a tuple of two 64 bit\n"
" signed integers\n"
"utupledigest() -- return the current digest as a tuple of two 64 bit\n"
" unsigned integers\n"
"copy() -- return a copy of the current object\n"
"\n"
"Attributes:\n"
"\n"
"name -- the hash algorithm being used by this object\n"
"digest_size -- number of bytes in this hashes output\n"
"block_size -- number of bytes of the internal block of this algorithm");
"hash of a string of information.");

static PyTypeObject MMH3Hasher128x86Type = {
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "mmh3.mmh3_x86_128",
Expand All @@ -1174,13 +1131,15 @@ static PyTypeObject MMH3Hasher128x86Type = {
static struct PyModuleDef mmh3module = {
PyModuleDef_HEAD_INIT,
"mmh3",
"mmh3 is a Python front-end to MurmurHash3, "
"a fast and robust hash library "
"created by Austin Appleby (http://code.google.com/p/smhasher/).\n "
"Ported by Hajime Senuma <hajime.senuma@gmail.com>\n"
"Try hash('foobar') or hash('foobar', 1984).\n"
"A Python front-end to MurmurHash3.\n\n"
"A Python front-end to MurmurHash3, "
"a fast and robust non-cryptographic hash library "
"created by Austin Appleby (http://code.google.com/p/smhasher/).\n\n"
"Ported by Hajime Senuma <[email protected]>. "
"If you find any bugs, please submit an issue via "
"https://github.com/hajimes/mmh3",
"https://github.com/hajimes/mmh3.\n\n"
"Typical usage example:\n\n"
" mmh3.hash('foobar', 42)",
-1,
Mmh3Methods,
NULL,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_doctrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ def test_function_docstrings() -> None:
def test_module_docstring() -> None:
assert "__doc__" in dir(mmh3)
assert mmh3.__doc__ is not None
assert mmh3.__doc__.startswith("mmh3 is a Python front-end to MurmurHash3")
assert mmh3.__doc__.startswith("A Python front-end to MurmurHash3")

0 comments on commit b14abef

Please sign in to comment.