spookyhash 2.1.1__tar.gz → 2.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {spookyhash-2.1.1/spookyhash.egg-info → spookyhash-2.1.2}/PKG-INFO +9 -6
  2. {spookyhash-2.1.1 → spookyhash-2.1.2}/README.md +1 -1
  3. {spookyhash-2.1.1 → spookyhash-2.1.2}/pyproject.toml +19 -9
  4. {spookyhash-2.1.1 → spookyhash-2.1.2}/setup.py +3 -2
  5. spookyhash-2.1.1/spookyhash.py → spookyhash-2.1.2/spookyhash/__init__.py +39 -36
  6. spookyhash-2.1.2/spookyhash/_spookyhash.pyi +25 -0
  7. spookyhash-2.1.2/spookyhash/py.typed +0 -0
  8. {spookyhash-2.1.1 → spookyhash-2.1.2/spookyhash.egg-info}/PKG-INFO +9 -6
  9. {spookyhash-2.1.1 → spookyhash-2.1.2}/spookyhash.egg-info/SOURCES.txt +4 -2
  10. spookyhash-2.1.2/spookyhash.egg-info/requires.txt +11 -0
  11. spookyhash-2.1.2/spookyhash.egg-info/top_level.txt +1 -0
  12. {spookyhash-2.1.1 → spookyhash-2.1.2}/src/spookyhash.pyx +1 -1
  13. spookyhash-2.1.2/tests/test_readme.py +50 -0
  14. spookyhash-2.1.2/tests/test_release.py +25 -0
  15. spookyhash-2.1.2/tests/test_spooky_hash.py +363 -0
  16. spookyhash-2.1.1/spookyhash.egg-info/requires.txt +0 -4
  17. spookyhash-2.1.1/spookyhash.egg-info/top_level.txt +0 -2
  18. spookyhash-2.1.1/src/spookyhash.cpp +0 -31321
  19. spookyhash-2.1.1/tests/test_readme.py +0 -50
  20. spookyhash-2.1.1/tests/test_spooky_hash.py +0 -217
  21. {spookyhash-2.1.1 → spookyhash-2.1.2}/LICENSE +0 -0
  22. {spookyhash-2.1.1 → spookyhash-2.1.2}/MANIFEST.in +0 -0
  23. {spookyhash-2.1.1 → spookyhash-2.1.2}/setup.cfg +0 -0
  24. {spookyhash-2.1.1 → spookyhash-2.1.2}/spookyhash.egg-info/dependency_links.txt +0 -0
  25. {spookyhash-2.1.1 → spookyhash-2.1.2}/src/SpookyV2.cpp +0 -0
  26. {spookyhash-2.1.1 → spookyhash-2.1.2}/src/SpookyV2.h +0 -0
  27. {spookyhash-2.1.1 → spookyhash-2.1.2}/src/SpookyV2.pxd +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spookyhash
3
- Version: 2.1.1
3
+ Version: 2.1.2
4
4
  Summary: A Python wrapper for SpookyHash version 2
5
5
  Author-email: Alen Buhanec <alen.buhanec@gmail.com>
6
- License: MIT
6
+ License-Expression: MIT
7
7
  Project-URL: Homepage, https://github.com/buhanec/spookyhash
8
8
  Project-URL: Repository, https://github.com/buhanec/spookyhash
9
9
  Project-URL: Issues, https://github.com/buhanec/spookyhash/issues
@@ -11,22 +11,25 @@ Keywords: SpookyHash,hashlib
11
11
  Classifier: Topic :: Software Development :: Libraries
12
12
  Classifier: Development Status :: 5 - Production/Stable
13
13
  Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.7
15
- Classifier: Programming Language :: Python :: 3.8
16
14
  Classifier: Programming Language :: Python :: 3.9
17
15
  Classifier: Programming Language :: Python :: 3.10
18
16
  Classifier: Programming Language :: Python :: 3.11
19
17
  Classifier: Programming Language :: Python :: 3.12
20
18
  Classifier: Programming Language :: Python :: 3.13
21
19
  Classifier: Programming Language :: Python :: 3.14
22
- Classifier: License :: OSI Approved :: MIT License
20
+ Classifier: Programming Language :: Python :: 3.15
23
21
  Classifier: Operating System :: OS Independent
24
22
  Classifier: Typing :: Typed
23
+ Requires-Python: >=3.9
25
24
  Description-Content-Type: text/markdown
26
25
  License-File: LICENSE
26
+ Provides-Extra: typing
27
+ Requires-Dist: mypy>=1.18; extra == "typing"
28
+ Requires-Dist: typing-extensions; extra == "typing"
27
29
  Provides-Extra: test
28
30
  Requires-Dist: pytest; extra == "test"
29
31
  Requires-Dist: hypothesis; extra == "test"
32
+ Requires-Dist: numpy; (python_version >= "3.11" or sys_platform != "win32" or platform_machine != "ARM64") and extra == "test"
30
33
  Dynamic: license-file
31
34
 
32
35
  # spookyhash
@@ -108,7 +111,7 @@ Includes `memoryview` compatible types, such as NumPy arrays.
108
111
  >>> import spookyhash
109
112
  >>> import numpy as np
110
113
 
111
- >>> spookyhash.Hash64(np.arange(100)).hexdigest()
114
+ >>> spookyhash.Hash64(np.arange(100, dtype=np.int32)).hexdigest()
112
115
  '43ab5363ad362c74'
113
116
 
114
117
  >>> spookyhash.Hash64(memoryview(b'hello world')).hexdigest()
@@ -77,7 +77,7 @@ Includes `memoryview` compatible types, such as NumPy arrays.
77
77
  >>> import spookyhash
78
78
  >>> import numpy as np
79
79
 
80
- >>> spookyhash.Hash64(np.arange(100)).hexdigest()
80
+ >>> spookyhash.Hash64(np.arange(100, dtype=np.int32)).hexdigest()
81
81
  '43ab5363ad362c74'
82
82
 
83
83
  >>> spookyhash.Hash64(memoryview(b'hello world')).hexdigest()
@@ -1,8 +1,7 @@
1
1
  [build-system]
2
2
  requires = [
3
- "setuptools>=42",
4
- "wheel",
5
- "cython"
3
+ "setuptools>=77",
4
+ "cython>=3.1",
6
5
  ]
7
6
  build-backend = "setuptools.build_meta"
8
7
 
@@ -11,21 +10,20 @@ authors = [{name = "Alen Buhanec", email = "alen.buhanec@gmail.com"}]
11
10
  name = "spookyhash"
12
11
  description = "A Python wrapper for SpookyHash version 2"
13
12
  readme = "README.md"
13
+ requires-python = ">=3.9"
14
14
  keywords = ["SpookyHash", "hashlib"]
15
- license = {text = "MIT"}
15
+ license = "MIT"
16
16
  classifiers = [
17
17
  "Topic :: Software Development :: Libraries",
18
18
  "Development Status :: 5 - Production/Stable",
19
19
  "Programming Language :: Python :: 3",
20
- "Programming Language :: Python :: 3.7",
21
- "Programming Language :: Python :: 3.8",
22
20
  "Programming Language :: Python :: 3.9",
23
21
  "Programming Language :: Python :: 3.10",
24
22
  "Programming Language :: Python :: 3.11",
25
23
  "Programming Language :: Python :: 3.12",
26
24
  "Programming Language :: Python :: 3.13",
27
25
  "Programming Language :: Python :: 3.14",
28
- "License :: OSI Approved :: MIT License",
26
+ "Programming Language :: Python :: 3.15",
29
27
  "Operating System :: OS Independent",
30
28
  "Typing :: Typed",
31
29
  ]
@@ -37,10 +35,22 @@ Repository = "https://github.com/buhanec/spookyhash"
37
35
  Issues = "https://github.com/buhanec/spookyhash/issues"
38
36
 
39
37
  [project.optional-dependencies]
40
- test = ["pytest", "hypothesis"]
38
+ typing = [
39
+ "mypy>=1.18",
40
+ "typing-extensions",
41
+ ]
42
+ test = [
43
+ "pytest",
44
+ "hypothesis",
45
+ # only publishes win_arm64 wheels for CPython 3.11+
46
+ "numpy; python_version >= '3.11' or sys_platform != 'win32' or platform_machine != 'ARM64'",
47
+ ]
41
48
 
42
49
  [tool.setuptools]
43
- py-modules = ["spookyhash"]
50
+ packages = ["spookyhash"]
51
+
52
+ [tool.setuptools.package-data]
53
+ spookyhash = ["py.typed", "_spookyhash.pyi"]
44
54
 
45
55
  [tool.setuptools.dynamic]
46
56
  version = {attr = "spookyhash.__version__"}
@@ -1,12 +1,11 @@
1
1
  from Cython.Build import cythonize
2
2
  from setuptools import Extension, setup
3
3
 
4
-
5
4
  setup(
6
5
  ext_modules=cythonize(
7
6
  [
8
7
  Extension(
9
- "_spookyhash",
8
+ "spookyhash._spookyhash",
10
9
  ["src/spookyhash.pyx", "src/SpookyV2.cpp"],
11
10
  language="c++",
12
11
  ),
@@ -17,6 +16,8 @@ setup(
17
16
  "wraparound": False,
18
17
  "embedsignature": True,
19
18
  "language_level": 3,
19
+ "freethreading_compatible": True,
20
20
  },
21
+ build_dir="build/cython",
21
22
  ),
22
23
  )
@@ -1,24 +1,28 @@
1
1
  """A Python wrapper for SpookyHash version 2."""
2
2
 
3
+ from __future__ import annotations
4
+
3
5
  import struct
6
+ import typing
4
7
  from abc import ABC, abstractmethod
5
8
  from binascii import hexlify
6
- from typing import ClassVar, TYPE_CHECKING, Tuple, Type, Union, cast
7
9
 
8
- import _spookyhash
10
+ from . import _spookyhash
11
+
12
+ if typing.TYPE_CHECKING:
13
+ import typing_extensions
9
14
 
10
- if TYPE_CHECKING:
11
- from typing import Self
15
+ _MessageT = bytes | memoryview[bytes] | typing_extensions.Buffer
12
16
 
13
- __all__ = ('hash32', 'hash64', 'hash128', 'Hash32', 'Hash64', 'Hash128')
14
- __version__ = '2.1.1'
17
+ __all__ = ("hash32", "hash64", "hash128", "Hash32", "Hash64", "Hash128")
18
+ __version__ = "2.1.2"
15
19
 
16
20
 
17
21
  # Utility function for homogenising data
18
22
 
19
- def _char_arr(message: Union[bytes, memoryview, None]) -> memoryview:
23
+ def _char_arr(message: _MessageT | None) -> memoryview[bytes]:
20
24
  if message is None:
21
- return memoryview(b'').cast('c')
25
+ return memoryview(b"").cast("c")
22
26
  if not isinstance(message, memoryview):
23
27
  try:
24
28
  message = memoryview(message)
@@ -29,14 +33,17 @@ def _char_arr(message: Union[bytes, memoryview, None]) -> memoryview:
29
33
  f"arrays); instead found "
30
34
  f"{type(message).__module__}.{type(message).__name__}"
31
35
  ) from e
32
- if message.format != 'c' or not message.contiguous:
33
- message = message.cast('c')
36
+ if message.format != "c" or not message.contiguous:
37
+ message = message.cast("c")
38
+ if typing.TYPE_CHECKING:
39
+ message = typing.cast(memoryview[bytes], message)
34
40
  return message
35
41
 
36
42
 
37
43
  # Oneshot hash functions
38
44
 
39
- def hash32(message: Union[bytes, memoryview], seed: int = 0) -> int:
45
+
46
+ def hash32(message: _MessageT, seed: int = 0) -> int:
40
47
  """
41
48
  Hash a single message in one call, produce 32-bit output.
42
49
 
@@ -47,7 +54,7 @@ def hash32(message: Union[bytes, memoryview], seed: int = 0) -> int:
47
54
  return _spookyhash.hash32(_char_arr(message), seed)
48
55
 
49
56
 
50
- def hash64(message: Union[bytes, memoryview], seed: int = 0) -> int:
57
+ def hash64(message: _MessageT, seed: int = 0) -> int:
51
58
  """
52
59
  Hash a single message in one call, produce 64-bit output.
53
60
 
@@ -59,10 +66,10 @@ def hash64(message: Union[bytes, memoryview], seed: int = 0) -> int:
59
66
 
60
67
 
61
68
  def hash128_pair(
62
- message: Union[bytes, memoryview],
69
+ message: _MessageT,
63
70
  seed1: int = 0,
64
71
  seed2: int = 0,
65
- ) -> Tuple[int, int]:
72
+ ) -> tuple[int, int]:
66
73
  """
67
74
  Hash a single message in one call, produce 128-bit output.
68
75
 
@@ -72,11 +79,11 @@ def hash128_pair(
72
79
  :return: Pair of 64-bit hash values
73
80
  """
74
81
  digest = _spookyhash.hash128(_char_arr(message), seed1=seed1, seed2=seed2)
75
- return cast(Tuple[int, int], struct.unpack('=QQ', digest))
82
+ return struct.unpack("=QQ", digest)
76
83
 
77
84
 
78
85
  def hash128(
79
- message: Union[bytes, memoryview],
86
+ message: _MessageT,
80
87
  seed1: int = 0,
81
88
  seed2: int = 0,
82
89
  ) -> int:
@@ -94,15 +101,16 @@ def hash128(
94
101
 
95
102
  # Incremental hash builders
96
103
 
104
+
97
105
  class Hash(ABC):
98
106
  """Base class for incremental hash builders."""
99
107
 
100
- digest_size: ClassVar[int]
101
- _hash_cls: ClassVar[Type[_spookyhash.Hash]]
108
+ digest_size: typing.ClassVar[int]
109
+ _hash_cls: typing.ClassVar[type[_spookyhash.Hash]]
102
110
 
103
111
  def __init__(
104
112
  self,
105
- message: Union[bytes, memoryview, None] = None,
113
+ message: _MessageT | None = None,
106
114
  seed1: int = 0,
107
115
  seed2: int = 0,
108
116
  ) -> None:
@@ -117,16 +125,11 @@ class Hash(ABC):
117
125
  if message is not None:
118
126
  self.update(message)
119
127
 
120
- @property
121
- def digest_size(self) -> int:
122
- """
123
- Digest size.
124
-
125
- :return: Digest size
126
- """
127
- return self._hash.digest_size
128
+ def __init_subclass__(cls) -> None:
129
+ super().__init_subclass__()
130
+ cls.digest_size = cls._hash_cls(0, 0).digest_size
128
131
 
129
- def update(self, message: Union[bytes, memoryview, None]) -> 'Self':
132
+ def update(self, message: _MessageT | None) -> typing_extensions.Self:
130
133
  """
131
134
  Incrementally update hash with message fragment.
132
135
 
@@ -151,7 +154,7 @@ class Hash(ABC):
151
154
 
152
155
  :return: Hex digest
153
156
  """
154
- return hexlify(self.digest()).decode('utf-8')
157
+ return hexlify(self.digest()).decode("utf-8")
155
158
 
156
159
  @abstractmethod
157
160
  def final(self) -> int:
@@ -160,7 +163,7 @@ class Hash(ABC):
160
163
 
161
164
  :return: Hash
162
165
  """
163
- return NotImplemented
166
+ raise NotImplementedError
164
167
 
165
168
 
166
169
  class Hash32(Hash):
@@ -170,7 +173,7 @@ class Hash32(Hash):
170
173
 
171
174
  def __init__(
172
175
  self,
173
- message: Union[bytes, memoryview, None] = None,
176
+ message: _MessageT | None = None,
174
177
  seed: int = 0,
175
178
  ) -> None:
176
179
  """
@@ -187,7 +190,7 @@ class Hash32(Hash):
187
190
 
188
191
  :return: Hash
189
192
  """
190
- return struct.unpack('=L', self.digest())[0]
193
+ return typing.cast(int, struct.unpack("=L", self.digest())[0])
191
194
 
192
195
 
193
196
  class Hash64(Hash):
@@ -196,7 +199,7 @@ class Hash64(Hash):
196
199
 
197
200
  def __init__(
198
201
  self,
199
- message: Union[bytes, memoryview, None] = None,
202
+ message: _MessageT | None = None,
200
203
  seed: int = 0,
201
204
  ) -> None:
202
205
  """
@@ -213,14 +216,14 @@ class Hash64(Hash):
213
216
 
214
217
  :return: Hash
215
218
  """
216
- return struct.unpack('=Q', self.digest())[0]
219
+ return typing.cast(int, struct.unpack("=Q", self.digest())[0])
217
220
 
218
221
 
219
222
  class Hash128(Hash):
220
223
 
221
224
  _hash_cls = _spookyhash.Hash128
222
225
 
223
- def final_pair(self) -> Tuple[int, int]:
226
+ def final_pair(self) -> tuple[int, int]:
224
227
  """
225
228
  Compute the hash for the concatenation of all message fragments.
226
229
 
@@ -228,7 +231,7 @@ class Hash128(Hash):
228
231
 
229
232
  :return: Pair of 64-bit integers representing the hash
230
233
  """
231
- return cast(Tuple[int, int], struct.unpack('=QQ', self.digest()))
234
+ return struct.unpack("=QQ", self.digest())
232
235
 
233
236
  def final(self) -> int:
234
237
  """
@@ -0,0 +1,25 @@
1
+ """Type stubs for SpookyHash Cython code."""
2
+
3
+ import typing
4
+
5
+ import typing_extensions
6
+
7
+ __all__ = ("hash32", "hash64", "hash128", "Hash", "Hash32", "Hash64", "Hash128")
8
+ __version__: str
9
+
10
+ def hash32(message: bytes | memoryview[bytes], seed: int = 0) -> int: ...
11
+ def hash64(message: bytes | memoryview[bytes], seed: int = 0) -> int: ...
12
+ def hash128(message: bytes | memoryview[bytes], seed1: int = 0, seed2: int = 0) -> bytes: ...
13
+
14
+ @typing_extensions.disjoint_base
15
+ class Hash:
16
+ def __new__(cls, seed1: int, seed2: int) -> typing_extensions.Self: ...
17
+
18
+ digest_size: int
19
+
20
+ def update(self, message: bytes | memoryview[bytes]) -> None: ...
21
+ def digest(self) -> bytes: ...
22
+
23
+ class Hash32(Hash): ...
24
+ class Hash64(Hash): ...
25
+ class Hash128(Hash): ...
File without changes
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spookyhash
3
- Version: 2.1.1
3
+ Version: 2.1.2
4
4
  Summary: A Python wrapper for SpookyHash version 2
5
5
  Author-email: Alen Buhanec <alen.buhanec@gmail.com>
6
- License: MIT
6
+ License-Expression: MIT
7
7
  Project-URL: Homepage, https://github.com/buhanec/spookyhash
8
8
  Project-URL: Repository, https://github.com/buhanec/spookyhash
9
9
  Project-URL: Issues, https://github.com/buhanec/spookyhash/issues
@@ -11,22 +11,25 @@ Keywords: SpookyHash,hashlib
11
11
  Classifier: Topic :: Software Development :: Libraries
12
12
  Classifier: Development Status :: 5 - Production/Stable
13
13
  Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.7
15
- Classifier: Programming Language :: Python :: 3.8
16
14
  Classifier: Programming Language :: Python :: 3.9
17
15
  Classifier: Programming Language :: Python :: 3.10
18
16
  Classifier: Programming Language :: Python :: 3.11
19
17
  Classifier: Programming Language :: Python :: 3.12
20
18
  Classifier: Programming Language :: Python :: 3.13
21
19
  Classifier: Programming Language :: Python :: 3.14
22
- Classifier: License :: OSI Approved :: MIT License
20
+ Classifier: Programming Language :: Python :: 3.15
23
21
  Classifier: Operating System :: OS Independent
24
22
  Classifier: Typing :: Typed
23
+ Requires-Python: >=3.9
25
24
  Description-Content-Type: text/markdown
26
25
  License-File: LICENSE
26
+ Provides-Extra: typing
27
+ Requires-Dist: mypy>=1.18; extra == "typing"
28
+ Requires-Dist: typing-extensions; extra == "typing"
27
29
  Provides-Extra: test
28
30
  Requires-Dist: pytest; extra == "test"
29
31
  Requires-Dist: hypothesis; extra == "test"
32
+ Requires-Dist: numpy; (python_version >= "3.11" or sys_platform != "win32" or platform_machine != "ARM64") and extra == "test"
30
33
  Dynamic: license-file
31
34
 
32
35
  # spookyhash
@@ -108,7 +111,7 @@ Includes `memoryview` compatible types, such as NumPy arrays.
108
111
  >>> import spookyhash
109
112
  >>> import numpy as np
110
113
 
111
- >>> spookyhash.Hash64(np.arange(100)).hexdigest()
114
+ >>> spookyhash.Hash64(np.arange(100, dtype=np.int32)).hexdigest()
112
115
  '43ab5363ad362c74'
113
116
 
114
117
  >>> spookyhash.Hash64(memoryview(b'hello world')).hexdigest()
@@ -3,7 +3,9 @@ MANIFEST.in
3
3
  README.md
4
4
  pyproject.toml
5
5
  setup.py
6
- spookyhash.py
6
+ spookyhash/__init__.py
7
+ spookyhash/_spookyhash.pyi
8
+ spookyhash/py.typed
7
9
  spookyhash.egg-info/PKG-INFO
8
10
  spookyhash.egg-info/SOURCES.txt
9
11
  spookyhash.egg-info/dependency_links.txt
@@ -12,7 +14,7 @@ spookyhash.egg-info/top_level.txt
12
14
  src/SpookyV2.cpp
13
15
  src/SpookyV2.h
14
16
  src/SpookyV2.pxd
15
- src/spookyhash.cpp
16
17
  src/spookyhash.pyx
17
18
  tests/test_readme.py
19
+ tests/test_release.py
18
20
  tests/test_spooky_hash.py
@@ -0,0 +1,11 @@
1
+
2
+ [test]
3
+ pytest
4
+ hypothesis
5
+
6
+ [test:python_version >= "3.11" or sys_platform != "win32" or platform_machine != "ARM64"]
7
+ numpy
8
+
9
+ [typing]
10
+ mypy>=1.18
11
+ typing-extensions
@@ -0,0 +1 @@
1
+ spookyhash
@@ -6,7 +6,7 @@ from libc.stdint cimport uint8_t, uint32_t, uint64_t
6
6
  cimport SpookyV2
7
7
 
8
8
  __all__ = ('hash32', 'hash64', 'hash128', 'Hash', 'Hash32', 'Hash64', 'Hash128')
9
- __version__ = '2.1.1'
9
+ __version__ = '2.1.2'
10
10
 
11
11
 
12
12
  # Oneshot hash functions
@@ -0,0 +1,50 @@
1
+ """Test README examples work as expected."""
2
+
3
+ import pytest
4
+
5
+ import spookyhash
6
+
7
+
8
+ def test_oneshot_hashes() -> None:
9
+ assert spookyhash.hash32(b"hello world") == 2617184861
10
+ assert spookyhash.hash32(b"hello world", seed=0x12345678) == 3380090220
11
+
12
+ assert spookyhash.hash64(b"hello world") == 14865987102431973981
13
+ assert spookyhash.hash64(b"hello world", seed=123) == 5719863273689036421
14
+
15
+ assert spookyhash.hash128(b"hello world") == 185933735475381961281710998418114941533
16
+ assert spookyhash.hash128(b"hello world", seed1=123_000, seed2=456_000) == 144121310386202441278894605216246194925
17
+
18
+ assert spookyhash.hash128_pair(b"hello world") == (14865987102431973981, 10079487997037711397)
19
+ assert spookyhash.hash128_pair(b"hello world", seed1=123_000, seed2=456_000) == (12678109464562819821, 7812831891108919044)
20
+
21
+
22
+ def test_incremental_hash32() -> None:
23
+ sh = spookyhash.Hash32()
24
+ sh.update(b"hello")
25
+ sh.update(b" ")
26
+ sh.update(b"world")
27
+ assert sh.final() == 2617184861
28
+ assert sh.hexdigest() == "5d12ff9b"
29
+
30
+
31
+ def test_incremental_hash64() -> None:
32
+ assert spookyhash.Hash64(b"hello ", seed=123).update(b"world").final() == 5719863273689036421
33
+ assert spookyhash.Hash64(b"hello ", seed=123).update(b"world").hexdigest() == "85b609a05709614f"
34
+
35
+
36
+ def test_incremental_hash128() -> None:
37
+ sh = spookyhash.Hash128(seed1=123_000, seed2=456_000)
38
+ sh.update(b"hello world")
39
+ assert sh.final() == 144121310386202441278894605216246194925
40
+ assert sh.final_pair() == (12678109464562819821, 7812831891108919044)
41
+ assert sh.hexdigest() == "ede2c8f262b1f1af04f763f735c16c6c"
42
+
43
+
44
+ def test_memoryview_support_np() -> None:
45
+ np = pytest.importorskip("numpy")
46
+ assert spookyhash.Hash64(np.arange(100, dtype=np.int32)).hexdigest() == "43ab5363ad362c74"
47
+
48
+
49
+ def test_memoryview_support() -> None:
50
+ assert spookyhash.Hash64(memoryview(b"hello world")).hexdigest() == "5d12ff9b81984ece"
@@ -0,0 +1,25 @@
1
+ """Quick and dirty tests to avoid recreating releases three times."""
2
+
3
+ import pathlib
4
+
5
+ import pytest
6
+
7
+ import spookyhash
8
+
9
+ root_path = pathlib.Path(__file__).parent.parent
10
+ changelog_path = root_path / "CHANGELOG.md"
11
+
12
+
13
+ def test_version_consistent() -> None:
14
+ """Ensure versions in spookyhash.py and spookyhash.pyx are consistent."""
15
+ assert spookyhash.__version__ == spookyhash._spookyhash.__version__
16
+
17
+
18
+ @pytest.mark.skipif(not changelog_path.exists(), reason="Changelog not found")
19
+ def test_version_changelog() -> None:
20
+ versions = [
21
+ line.split()[1]
22
+ for line in changelog_path.read_text().splitlines()
23
+ if line.startswith("##")
24
+ ]
25
+ assert versions[0] == f"v{spookyhash.__version__}"