sqlite-vec/bindings/python/extra_init.py
Alex Garcia bf2455f2ba Add ANN search support for vec0 virtual table
Add approximate nearest neighbor infrastructure to vec0: shared distance
dispatch (vec0_distance_full), flat index type with parser, NEON-optimized
cosine/Hamming for float32/int8, amalgamation script, and benchmark suite
(benchmarks-ann/) with ground-truth generation and profiling tools. Remove
unused vec_npy_each/vec_static_blobs code, fix missing stdint.h include.
2026-03-29 19:44:44 -07:00

14 lines
419 B
Python

from typing import List
from struct import pack
def serialize_float32(vector: List[float]) -> bytes:
"""Serializes a list of floats into the "raw bytes" format sqlite-vec expects"""
return pack("%sf" % len(vector), *vector)
def serialize_int8(vector: List[int]) -> bytes:
"""Serializes a list of integers into the "raw bytes" format sqlite-vec expects"""
return pack("%sb" % len(vector), *vector)