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.0a3.tar.gz (84.0 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.0a3-py3-none-win_amd64.whl (297.0 kB view details)

Uploaded Python 3Windows x86-64

surgedb-1.0.0a3-py3-none-manylinux_2_34_x86_64.whl (431.6 kB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

surgedb-1.0.0a3-py3-none-manylinux_2_34_aarch64.whl (422.2 kB view details)

Uploaded Python 3manylinux: glibc 2.34+ ARM64

surgedb-1.0.0a3-py3-none-macosx_11_0_arm64.whl (385.6 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

surgedb-1.0.0a3-py3-none-macosx_10_12_x86_64.whl (399.7 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: surgedb-1.0.0a3.tar.gz
  • Upload date:
  • Size: 84.0 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.0a3.tar.gz
Algorithm Hash digest
SHA256 0d242dfd7189a47fda0c472c9175152b59662692753a21b42afa9459f9043980
MD5 a7756b8239fb53a665fca53650790170
BLAKE2b-256 cb5b413130a2dc4e1ba9c4dbed5405b5ea9058edd4cff74d3147e5d76c39162f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: surgedb-1.0.0a3-py3-none-win_amd64.whl
  • Upload date:
  • Size: 297.0 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.0a3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 8e1d0fe712f8b6dcf9324cb992c1688d7ff22e1ae6846c64adf552db656188c7
MD5 eca41a8596822e542253ffbcce0e1f3e
BLAKE2b-256 c3a6579141be0d5b040f99cbaa8c5474429bec4010de585902b82d37fcd9f7d0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for surgedb-1.0.0a3-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 49261505560ab17836613e17bf927ea5972076b82da89d21a47dded269e33095
MD5 2f53e3d620498124200f64982b519bd9
BLAKE2b-256 4cf9aeccfffc566c0830c0e6d07d694cf2ad2e2fc530ec9ccf5d5c549312eaea

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for surgedb-1.0.0a3-py3-none-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 92d1e6a7c4d9f46ec501f984598b2f8497a249bba9b8345cea7b56be8969a147
MD5 a0a2d135c8b5de47daaed0ffd8782f41
BLAKE2b-256 bea8d8b6e0b9b0c5e7192837240ffc56410081d42ae99d967ef6586d4356019e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for surgedb-1.0.0a3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 074d3473ebeb74ecac4aa869cdce93236ad486b63c2b50f340309f2ba726b6ff
MD5 5ceb36924e439a3004daf09dab5b82bd
BLAKE2b-256 431a6cb000baaa383f8f68450f9d8f0b4d08281b4a91d93d3567ab0fbc22f09c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for surgedb-1.0.0a3-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 80f652cc467d9c30e0684cdaeea71a005eb3c5842d139661d701062d7eeb9c1c
MD5 33343be3a28e6c33f53c865754f39764
BLAKE2b-256 2327455b98005d7c9edfe7753c2cd88a05ce445ecd6e6382d28d9050eeb7e61f

See more details on using hashes here.

Provenance

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