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.0a2.tar.gz (83.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.0a2-py3-none-win_amd64.whl (296.4 kB view details)

Uploaded Python 3Windows x86-64

surgedb-1.0.0a2-py3-none-manylinux_2_34_x86_64.whl (430.6 kB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

surgedb-1.0.0a2-py3-none-manylinux_2_34_aarch64.whl (420.8 kB view details)

Uploaded Python 3manylinux: glibc 2.34+ ARM64

surgedb-1.0.0a2-py3-none-macosx_11_0_arm64.whl (384.2 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

surgedb-1.0.0a2-py3-none-macosx_10_12_x86_64.whl (397.8 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: surgedb-1.0.0a2.tar.gz
  • Upload date:
  • Size: 83.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.0a2.tar.gz
Algorithm Hash digest
SHA256 e70a716750193700039c7a2ba4c7db6664fad6138f0ca433f965570fe93ed174
MD5 25e908dd26a9d54b193c10fd1b2d9aa4
BLAKE2b-256 90fa867bd0a5e94efd993fb08eaf89e2636264a75d0dba641fc64bfc43747f55

See more details on using hashes here.

Provenance

The following attestation bundles were made for surgedb-1.0.0a2.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.0a2-py3-none-win_amd64.whl.

File metadata

  • Download URL: surgedb-1.0.0a2-py3-none-win_amd64.whl
  • Upload date:
  • Size: 296.4 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.0a2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 63242c965cd77281819b3892ac96a4d015603c7092be000c457db57af01b1912
MD5 354a196a4cab692ec1d74d58839ede56
BLAKE2b-256 a38c1ca52228e6f8211d317adfdd5b2a5d6d31032b44d54b19473b6cd9fc4d85

See more details on using hashes here.

Provenance

The following attestation bundles were made for surgedb-1.0.0a2-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.0a2-py3-none-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for surgedb-1.0.0a2-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 80a2d958f48f0fe5bef820f7d0e2c84b09fca5957460a290608a64786dde1e2e
MD5 703e616b587db718a9fef4af1e1228cc
BLAKE2b-256 e23cecbca3b4e6c35eaa7e61764a97d0f9b7662da7cbff0d355dcce00a6f5996

See more details on using hashes here.

Provenance

The following attestation bundles were made for surgedb-1.0.0a2-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.0a2-py3-none-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for surgedb-1.0.0a2-py3-none-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 8cc7c4fded09a71c33bd52063f2452082c53b49a6391b87d4a854f5e99aadaa6
MD5 071f1ac072eaa5521a6077ff9c4ff952
BLAKE2b-256 656b1cca1219e2bc128460421e47df86e08467f80a8c9a2bbed319a4c3431e28

See more details on using hashes here.

Provenance

The following attestation bundles were made for surgedb-1.0.0a2-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.0a2-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for surgedb-1.0.0a2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 56be4ee47e31ca465e976184b2d76936c6875ad85fcf3eab742d88d0020031bf
MD5 df952504e37ba501411bde3aa92d90c9
BLAKE2b-256 99670bbe6cc0ddbf6ebe3085adb513816e04d0a79a10dca33c59af56460b89ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for surgedb-1.0.0a2-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.0a2-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for surgedb-1.0.0a2-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 33244871fca1c7c5cc2afe26ffa0cede92b9ba471112fca8d765b9a8839c513b
MD5 46e1c8b726db21a0ed3902127e18c571
BLAKE2b-256 0338cca367856ff7f0fc5ad7c63eb6b063b732399dd2a9c9f677f463246101ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for surgedb-1.0.0a2-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