Skip to content

Commit

Permalink
Add funcs for non-immutables w/o copying (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimes authored Sep 11, 2024
1 parent bff23fa commit 3b1fff4
Show file tree
Hide file tree
Showing 8 changed files with 818 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,6 @@ ENV/

# macOS
.DS_Store

# vscode
.vscode/
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ This project has adhered to

### Added

- Add `digest` functions that accept a non-immutable buffer as input
and process it without internal copying.
- Slightly improve the performance of the `hash_bytes` function.
- Add support for Python 3.13.
- Add Read the Docs documentation (<https://github.com/hajimes/mmh3/issues/54>).
Expand All @@ -21,6 +23,10 @@ This project has adhered to
- Change the format of CHANGELOG.md to conform to the Keep a Changelog
standard.

### Fixed

- Fix a reference leak in the `hash_from_buffer()` function.

## [4.1.0] - 2024-01-09

### Added
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,23 @@ complete changelog.

#### Added

- Add `digest` functions that accept a non-immutable buffer as input
and process it without internal copying.
- Slightly improve the performance of the `hash_bytes` function.
- Add support for Python 3.13.
- Add Read the Docs documentation (<https://github.com/hajimes/mmh3/issues/54>).
- (planned: Document benchmark results
(<https://github.com/hajimes/mmh3/issues/53>)).

#### Changed
### Changed

- Change the format of CHANGELOG.md to conform to the Keep a Changelog
standard.

### Fixed

- Fix a reference leak in the `hash_from_buffer()` function.

### [4.1.0] - 2024-01-09

#### Added
Expand Down
4 changes: 2 additions & 2 deletions benchmark/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
MASK: Final[int] = 0xFFFFFFFFFFFFFFFF

HASHES = {
"mmh3_32": mmh3.hash,
"mmh3_128": mmh3.hash_bytes,
"mmh3_32": mmh3.mmh3_32_digest,
"mmh3_128": mmh3.mmh3_x64_128_digest,
"xxh_32": xxhash.xxh32_digest,
"xxh_64": xxhash.xxh64_digest,
"xxh3_64": xxhash.xxh3_64_digest,
Expand Down
3 changes: 3 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
API Reference
================

.. caution::
This reference contains functions that are not yet released in the stable version.

.. automodule:: mmh3
:members:
:undoc-members:
Expand Down
21 changes: 19 additions & 2 deletions src/mmh3/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,26 @@ StrHashable = Union[str, Hashable]

def hash(key: StrHashable, seed: int = 0, signed: bool = True) -> int: ...
def hash_from_buffer(key: StrHashable, seed: int = 0, signed: bool = True) -> int: ...
def hash64(key: StrHashable, seed: int = 0, x64arch:bool = True, signed: bool = True) -> tuple[int, int]: ...
def hash128(key: StrHashable, seed: int = 0, x64arch:bool = True, signed: bool = False) -> int: ...
def hash64(
key: StrHashable, seed: int = 0, x64arch: bool = True, signed: bool = True
) -> tuple[int, int]: ...
def hash128(
key: StrHashable, seed: int = 0, x64arch: bool = True, signed: bool = False
) -> int: ...
def hash_bytes(key: StrHashable, seed: int = 0, x64arch: bool = True) -> bytes: ...
def mmh3_32_digest(key: StrHashable, seed: int = 0) -> bytes: ...
def mmh3_32_sintdigest(key: StrHashable, seed: int = 0) -> int: ...
def mmh3_32_uintdigest(key: StrHashable, seed: int = 0) -> int: ...
def mmh3_x64_128_digest(key: StrHashable, seed: int = 0) -> bytes: ...
def mmh3_x64_128_sintdigest(key: StrHashable, seed: int = 0) -> int: ...
def mmh3_x64_128_uintdigest(key: StrHashable, seed: int = 0) -> int: ...
def mmh3_x64_128_stupledigest(key: StrHashable, seed: int = 0) -> tuple[int, int]: ...
def mmh3_x64_128_utupledigest(key: StrHashable, seed: int = 0) -> tuple[int, int]: ...
def mmh3_x86_128_digest(key: StrHashable, seed: int = 0) -> bytes: ...
def mmh3_x86_128_sintdigest(key: StrHashable, seed: int = 0) -> int: ...
def mmh3_x86_128_uintdigest(key: StrHashable, seed: int = 0) -> int: ...
def mmh3_x86_128_stupledigest(key: StrHashable, seed: int = 0) -> tuple[int, int]: ...
def mmh3_x86_128_utupledigest(key: StrHashable, seed: int = 0) -> tuple[int, int]: ...

class Hasher:
def __init__(self, seed: int = 0) -> None: ...
Expand Down
Loading

0 comments on commit 3b1fff4

Please sign in to comment.