diff --git a/bindings/go/ncruces/go-sqlite3 b/bindings/go/ncruces/go-sqlite3 new file mode 160000 index 0000000..21de85e --- /dev/null +++ b/bindings/go/ncruces/go-sqlite3 @@ -0,0 +1 @@ +Subproject commit 21de85e849b7660b9b527535b1999f942084fd02 diff --git a/bindings/python/extra_init.py b/bindings/python/extra_init.py new file mode 100644 index 0000000..6c332ff --- /dev/null +++ b/bindings/python/extra_init.py @@ -0,0 +1,46 @@ + +from typing import List +from struct import pack +from sqlite3 import Connection + +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) + +def serialize_(vector: List[int]) -> bytes: + """ Serializes a list of integers into the "raw bytes" format sqlite-vec expects """ + return pack("%sb" % len(vector), *vector) + +try: + import numpy.typing as npt + + def register_numpy(db: Connection, name:str, array: npt.NDArray): + """ayoo""" + + ptr = array.__array_interface__["data"][0] + nvectors, dimensions = array.__array_interface__["shape"] + element_type = array.__array_interface__["typestr"] + + assert element_type == "