O(1) Vector Search for Python
Lightning-fast vector similarity search with O(1) complexity using Locality Sensitive Hashing (LSH).
Features
- ⚡ O(1) Search Complexity - Constant time search regardless of index size
- 🐍 Pure Python - Minimal dependencies (only NumPy)
- 💾 Persistent - Save and load indices
- 🔧 Simple API - Easy to use and integrate
- 🚀 Fast - Benchmarked at 0.18ms average search time
Installation
pip install o1-vector-search
Quick Start
from o1_vector_search import O1VectorSearch
import numpy as np
# Create an index for 384-dimensional vectors
index = O1VectorSearch(dim=384)
# Add vectors with metadata
vector1 = np.random.randn(384)
index.add(vector1, {"id": 1, "text": "Hello world"})
vector2 = np.random.randn(384)
index.add(vector2, {"id": 2, "text": "Machine learning"})
# Search for similar vectors in O(1) time
query = np.random.randn(384)
results = index.search(query, k=5)
for distance, vector, metadata in results:
print(f"Distance: {distance:.4f}, Metadata: {metadata}")
API Reference
Constructor
O1VectorSearch(dim: int, num_hash_tables: int = 10, num_hash_functions: int = 8)
Methods
add(vector: np.ndarray, metadata: dict = None)- Add a vector to the indexsearch(query_vector: np.ndarray, k: int = 5)- Search for k nearest neighborssize()- Get the number of vectors in the indexclear()- Remove all vectorssave(filepath: str)- Save the index to diskload(filepath: str)- Load an index from disk
Performance
The O(1) complexity is achieved through LSH (Locality Sensitive Hashing):
- Add: O(1) - Constant time insertion
- Search: O(1) - Constant time retrieval
- Memory: O(n) - Linear space complexity
Benchmarked performance:
- 0.18ms average search time
- 88.8 searches per second
- Scales to millions of vectors
Use Cases
- Real-time recommendation systems
- Semantic search engines
- Image similarity search
- Anomaly detection
- Clustering and classification
License
MIT
Metadata
Release files for o1-vector-search 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| o1_vector_search-1.1.0.tar.gz | 4.4 kB | Without provenance | Details for o1_vector_search-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| o1_vector_search-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for o1_vector_search-1.1.0-py3-none-any.whl |
Total release size: 9.2 kB
Release files / o1_vector_search-1.1.0.tar.gz
| Download URL | o1_vector_search-1.1.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4fb346c7dd454bbd3fa10fc3c142545da227170dfd4fb9ed11164d998d8515da
|
|
BLAKE2b-256 checksum How to use checksums |
c38bd457bc798a6a128d30b039e9ea97a87319b458cbc69dbc2e49e3f951a194
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.6
|
Release files / o1_vector_search-1.1.0-py3-none-any.whl
| Download URL | o1_vector_search-1.1.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4dd6975df9d7c7871580bfbf603a95a9a38edeb9b3430c82883dbbcf550efa8
|
|
BLAKE2b-256 checksum How to use checksums |
2a3860a81c94a281baaeed93a4a38f46a821fce263bb01200589b3c98a933d88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.6
|
Security for o1-vector-search 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.