CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-xxhash

Python binding for xxHash library providing fast non-cryptographic hash algorithms

Overall
score

80%

Evaluation80%

1.03x

Agent success when using this tile

Overview
Eval results
Files

task.mdevals/scenario-4/

Multi-format Data Hasher

Build a utility that computes hash digests for data provided in different buffer-like formats.

Requirements

Create a module that exports a single function hash_data which:

  1. Accepts data in any of the following formats: bytes, bytearray, array.array (of type 'B' for unsigned bytes), or memoryview
  2. Computes a 64-bit hash of the input data
  3. Returns the hash as a hexadecimal string
  4. Raises a TypeError if the input is not one of the supported buffer-like types

The function should handle all buffer-like input types correctly and produce consistent hash values for equivalent data regardless of the input format.

Test Cases

  • Hashing bytes b'hello world' returns a hexadecimal string @test
  • Hashing bytearray(b'hello world') returns the same hash as bytes b'hello world' @test
  • Hashing array.array('B', [104, 101, 108, 108, 111]) returns a valid hexadecimal string @test
  • Hashing memoryview(b'test data') returns a valid hexadecimal string @test
  • Passing a string 'invalid' raises TypeError @test
  • Passing None raises TypeError @test

Implementation

@generates

API

def hash_data(data):
    """
    Compute a 64-bit hash for buffer-like input data.

    Args:
        data: Input data in bytes, bytearray, array.array, or memoryview format

    Returns:
        str: Hexadecimal string representation of the hash

    Raises:
        TypeError: If data is not a supported buffer-like type
    """
    pass

Dependencies { .dependencies }

xxhash { .dependency }

Provides fast non-cryptographic hash functions.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-xxhash

tile.json