Skip to content

Conversation

@rodrigobnogueira
Copy link

Description

Implements the xxHash32 algorithm, an extremely fast non-cryptographic hash function designed to operate at RAM speed limits. xxHash is widely used in high-performance applications.

Changes

  • Added hashes/xxhash.py with complete implementation
  • Uses 4 parallel accumulators for maximum speed
  • Processes data in optimized 16-byte stripes
  • Carefully selected prime constants (0x9E3779B1, etc.)
  • Optional seed parameter for hash variation
  • 15 comprehensive doctests including:
    • Empty and small inputs
    • Large inputs
    • Edge cases (null bytes)
    • Seed functionality

Features

  • Fast: One of the fastest hash algorithms
  • Excellent distribution: Passes SMHasher test suite
  • Production-ready: Used in Zstandard, LZ4, rsync
  • Seed support: Optional seed for different hash families

Testing

  • All 15 doctests pass
  • Passes ruff linting
  • Passes mypy type checking
  • Tested with various inputs and seeds

Checklist

  • Code follows project style guidelines
  • Type hints included
  • Doctests included and passing
  • English documentation with references
  • No external dependencies

- Implement xxHash32 with 4-accumulator parallel processing
- Add 15 comprehensive doctests with seed support
- Full type hints and English documentation
- Passes ruff and mypy checks

xxHash is extremely fast and used in Zstandard, LZ4, and rsync.
Features optimized processing with carefully selected prime constants.
@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Dec 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant