Python · Keys

Keys

from usearch import Key 3.0.0-rc.1 · 4c3e5023

Keys are 128 bits wide and render as lowercase dashed UUIDs. Integer keys sit in the low eight bytes, so Key(42) prints as 00000000-0000-0000-0000-00000000002a, and keys need not be unique: several entries may share one, and count reports how many.

import uuid
from usearch import Key

Key(42)  # from an integer
Key("00000000-0000-0000-0000-00000000002a")  # from the dashed rendering
Key(uuid.uuid4())  # from a `uuid.UUID`

A key equals and hashes as the integer or uuid.UUID it reads as, never as the text or bytes it parses from, and pickles as its sixteen bytes. No NumPy dtype expresses a 128-bit integer, so batch keys travel in both directions as big-endian sixteen-byte rows, an (N, 16) buffer of uint8. usearch.keys carries integers_to_keys and keys_to_integers for the common case where keys really are just entry numbers.

API

ClassKeyA 128-bit entry identity, rendered as a lowercase dashed UUID.2
lib.pyi:374 ↗
class Key
Key
lib.pyi:378 ↗
Key(value: _KeyLike = 0, /)
bytesThe sixteen identity bytes, most significant first.
lib.pyi:380 ↗
bytes: bytes