Skip to main content

A high-performance, lightweight vector database

Project description

SurgeDB Python

PyPI Python versions License

SurgeDB is a high-performance, embedded vector database for Python. It runs entirely locally—no Docker containers, no external APIs, and no complex setup required.

Built in Rust and powered by SIMD-accelerated HNSW indices, SurgeDB offers millisecond-latency vector search with a minimal memory footprint.


Key Features

  • 🚀 Blazing Fast: Hand-tuned AVX-512 and NEON kernels for maximum throughput.
  • 🧠 Memory Efficient: Built-in SQ8 (4x) and Binary (32x) quantization. Index millions of vectors on a laptop.
  • 📦 Embedded: Runs in-process. Just pip install and go.
  • 💾 Persistent: ACID-compliant storage with Write-Ahead Logs (WAL) and crash-safe snapshots.
  • 🔍 Rich Filtering: Filter search results by metadata (exact match, comparison, logical operators).

Installation

pip install surgedb

Quick Start

from surgedb import SurgeClient, SurgeConfig, DistanceMetric, Quantization

# 1. Initialize a persistent database
config = SurgeConfig(
    dimensions=384,                     # e.g., for all-MiniLM-L6-v2
    distance_metric=DistanceMetric.COSINE,
    quantization=Quantization.SQ8,      # 4x compression
    persistent=True,
    data_path="./my_vector_db"
)
db = SurgeClient.open("./my_vector_db", config)

# 2. Insert data (ID, Vector, Metadata)
db.insert(
    "doc_1", 
    [0.1, 0.2, 0.3, ...],               # 384-dim list or numpy array
    '{"title": "How to train your dragon", "tag": "movie"}'
)

# 3. Search with metadata filtering
results = db.search_with_filter(
    query=[0.1, 0.2, 0.3, ...], 
    k=5, 
    filter={'Exact': {'field': 'tag', 'value': 'movie'}}
)

for result in results:
    print(f"ID: {result.id}, Score: {result.score:.4f}")

Advanced Usage

Batch Operations

For maximum write throughput, use upsert_batch.

vectors = []
for i in range(1000):
    vectors.append({
        "id": f"vec_{i}",
        "vector": [0.1] * 384,
        "metadata": {"index": i}
    })

db.upsert_batch(vectors)

Metadata Filtering

SurgeDB supports a structured query language for filtering.

from surgedb import SearchFilter

# Find movies released after 2020 OR in the "Sci-Fi" genre
filter_query = SearchFilter.Or([
    SearchFilter.Comparison(field="year", operator="gt", value=2020),
    SearchFilter.Exact(field="genre", value="Sci-Fi")
])

results = db.search_with_filter(query_vec, 10, filter_query)

Performance

SurgeDB is designed to outperform pure-Python solutions and compete with heavy C++ vector stores, while remaining lightweight.

Metric Performance
Search Latency < 1ms (1M vectors, SQ8)
Indexing Speed ~20k vectors/sec
Memory (1M vectors) ~120MB (SQ8) vs ~4GB (Float32)
Cold Start < 50ms

Development

If you want to contribute to the bindings or build from source:

Prerequisites

  • Rust toolchain (stable)
  • Python 3.7+
  • maturin build tool

Building from Source

# Install maturin
pip install maturin

# Build and install locally
maturin develop --release -m crates/surgedb-bindings/Cargo.toml

Generating Bindings (UniFFI)

The bindings are automatically generated using UniFFI.

cd crates/surgedb-bindings
make generate-python

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

surgedb-1.0.0a5.tar.gz (85.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

surgedb-1.0.0a5-py3-none-win_amd64.whl (300.9 kB view details)

Uploaded Python 3Windows x86-64

surgedb-1.0.0a5-py3-none-manylinux_2_34_x86_64.whl (434.7 kB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

surgedb-1.0.0a5-py3-none-manylinux_2_34_aarch64.whl (425.6 kB view details)

Uploaded Python 3manylinux: glibc 2.34+ ARM64

surgedb-1.0.0a5-py3-none-macosx_11_0_arm64.whl (388.3 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

surgedb-1.0.0a5-py3-none-macosx_10_12_x86_64.whl (405.1 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file surgedb-1.0.0a5.tar.gz.

File metadata

  • Download URL: surgedb-1.0.0a5.tar.gz
  • Upload date:
  • Size: 85.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for surgedb-1.0.0a5.tar.gz
Algorithm Hash digest
SHA256 a6975c1d69b3008977eb12b8ebd79f378f9eceb18092f6e6aa1d5146a0cdc959
MD5 1267dc1752327292f106a8a8e9be2ff4
BLAKE2b-256 473a8a91512b1df22ad201ae929f07ede2636efe6c92044ef4c37d5c530e3849

See more details on using hashes here.

Provenance

The following attestation bundles were made for surgedb-1.0.0a5.tar.gz:

Publisher: release-pypi.yml on meet447/SurgeDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file surgedb-1.0.0a5-py3-none-win_amd64.whl.

File metadata

  • Download URL: surgedb-1.0.0a5-py3-none-win_amd64.whl
  • Upload date:
  • Size: 300.9 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for surgedb-1.0.0a5-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 77efa18893a45120067ca6cadf1b33369a1c6767010c3dc4d5d45e024d89712b
MD5 fdcf89a536e8a8cbac1ce89630f67501
BLAKE2b-256 b23489ea02da12c64d9c231817fb5daa8ad01559d14c4f98659de4e39a5e0495

See more details on using hashes here.

Provenance

The following attestation bundles were made for surgedb-1.0.0a5-py3-none-win_amd64.whl:

Publisher: release-pypi.yml on meet447/SurgeDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file surgedb-1.0.0a5-py3-none-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for surgedb-1.0.0a5-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1367e2f0becbae6e0b370b5c88694e4878513369c0d68f373c8ac37df90dabe0
MD5 08c8306cedbed64b809926c95de6564d
BLAKE2b-256 cd874fc615d2081551a19b68e662715bbd9b21fb7ba280dcc67d159a1f0b8da6

See more details on using hashes here.

Provenance

The following attestation bundles were made for surgedb-1.0.0a5-py3-none-manylinux_2_34_x86_64.whl:

Publisher: release-pypi.yml on meet447/SurgeDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file surgedb-1.0.0a5-py3-none-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for surgedb-1.0.0a5-py3-none-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 7b10ccd4848e65dd499f3d097a47c77e3af0ea095434e9c72a1d6355a1eaf62f
MD5 e0d09124d1435357b0baacccad0bdc96
BLAKE2b-256 3ecf0a386dfcd1afc82ef0f8afde108ae9467748b48ff2f233faa3d581340ff5

See more details on using hashes here.

Provenance

The following attestation bundles were made for surgedb-1.0.0a5-py3-none-manylinux_2_34_aarch64.whl:

Publisher: release-pypi.yml on meet447/SurgeDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file surgedb-1.0.0a5-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for surgedb-1.0.0a5-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 363ecb3a41afe33a163cd8d401dd3ece3d8d57101b9da42e3f22f2608a5f039a
MD5 571d12d00b8657e05984827bc2a57780
BLAKE2b-256 cac43a01adde00bf13701ceb9ee867157b17b3c4aa96b5032c59ba553688feda

See more details on using hashes here.

Provenance

The following attestation bundles were made for surgedb-1.0.0a5-py3-none-macosx_11_0_arm64.whl:

Publisher: release-pypi.yml on meet447/SurgeDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file surgedb-1.0.0a5-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for surgedb-1.0.0a5-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7e55a1e8c140b2668202455137692884c63e57b0d038034505c6b1f52f4fb240
MD5 1c343f9375ee3d6333d30706d035b2bd
BLAKE2b-256 f9884e627a940e5a04476a5f946b3078b80ad3227372cb26a9fba1244bc7f002

See more details on using hashes here.

Provenance

The following attestation bundles were made for surgedb-1.0.0a5-py3-none-macosx_10_12_x86_64.whl:

Publisher: release-pypi.yml on meet447/SurgeDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page