Py

PyNear – exact and approximate KNN, faster than Faiss

Hacker News

PyNear – exact and approximate KNN, faster than Faiss

PyNear is a Python KNN library built around Vantage-Point Trees with a C++ SIMD core. I've been working on it for a while and just shipped v2.2 with two new approximate binary indices. Benchmarks surprised me so I wanted to share. * Where it beats Faiss: - Exact L2 search — VP-Trees prune aggressively using the triangle inequality. At d=512, N=500k: 2.2 ms vs Faiss IndexFlatL2's 85 ms (39×). At low dimensionality (d≤16) it's 2–4× faster. - Approximate binary search — This one was unexpected. The new MIHBinaryIndex (Multi-Index Hashing) splits 512-bit descriptors into 8 sub-tables of 64-bit keys. By the pigeonhole principle, any true neighbour within Hamming radius 8 must match at least one sub-table exactly or with 1 bit flip — so each query is just 520 hash lookups instead of a linear scan. At N=1M, d=512: 0.037 ms vs Faiss IndexBinaryFlat's 9.5 ms (257×), with 100% Recall@10. - Faiss's approximate binary index (IndexBinaryIVF) turned out to have an O(N²) bug in its add() path — 34 minutes to build at N=1M. So in practice Faiss can't do approximate binary search at scale. * Where Faiss still wins: - Approximate float search at very large N (≥500k) and very high d — their compiled BLAS K-Means is faster than ours for big clustering jobs. If you're doing CLIP or LLM embedding retrieval at scale, Faiss IVF is still the right tool. Other things PyNear does that Faiss doesn't: - Pure Python install (NumPy only, no compiled native lib to manage) - Pickle serialization out of the box - L1, L∞, and Hamming exact search with the same API - Drop-in scikit-learn adapter (same fit/predict/kneighbors interface) - BKTree for Hamming range/threshold queries The binary approximate story is the most practically interesting to me — binary descriptors (ORB, BRIEF, AKAZE) are always high-dimensional and always approximate in practice, and it turns out MIH is a much better fit for that problem than IVF. GitHub: https://github.com/pablocael/pynear Benchmark report (PDF): https://github.com/pablocael/pynear/blob/main/docs/benchmarks.pdf

Share card

Actual performance

2points
Did not reach leaderboard

Launch Intel predictions

Analyze your own launch →
Product HuntOn track for Day 1 leaderboard · Strong signals: new, using · Missing: mac, agents, macos
77%77% predicted probability of success on Product Hunt, based on ML models trained on real launch data.
best fitHighest predicted score across all platforms for this description.
Hacker NewsMay not resonate with HN audience · Strong signals: io · Missing: https docs, excited, just released
48%48% predicted probability of success on Hacker News, based on ML models trained on real launch data.
nativeThis product was originally launched on this platform.
AppSumoMay struggle as an AppSumo deal · Strong signals: interface · Missing: plus, platform, intuitive
45%45% predicted probability of success on AppSumo, based on ML models trained on real launch data.
Indie HackersIH features products with proven revenue · Missing: supports, reddit linkedin, podcasting
44%44% predicted probability of success on Indie Hackers, based on ML models trained on real launch data.
TrustMRRLess likely to generate early MRR · Strong signals: way · Missing: mobile apps, ios, personal
41%41% predicted probability of success on TrustMRR, based on ML models trained on real launch data.
Acquire.comPre-revenue stage for this audience · Missing: arr, mrr, revenue
21%21% predicted probability of success on Acquire.com, based on ML models trained on real launch data.
BetaListMay not resonate with beta-testers · Missing: web3, chat, crypto
0%0% predicted probability of success on BetaList, based on ML models trained on real launch data.

Correct prediction on native model

Similar products

FIRECalculatorHQ
FIRECalculatorHQ34%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Find the exact year work becomes optional

Indie Hackers1finance
Fa
Faster exceptions without the ceremony66%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Faster exceptions without the ceremony

Hacker News3
Fa
Faster HyperLogLog Implementation57%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Faster HyperLogLog Implementation

Hacker News1
Pl
Plenc- Faster Serialization in Go48%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Plenc- Faster Serialization in Go

Hacker News2
Fa
Faster Integer Parsing61%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Faster Integer Parsing

Hacker News2
Fa
Faster Stable Diffusion70%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Faster Stable Diffusion

Hacker News1
Ho
How we made querying Pandas DataFrames 87x faster48%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

How we made querying Pandas DataFrames 87x faster

Hacker News2
Fa
Faster Than CGAL Delaunay in Julia66%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Faster Than CGAL Delaunay in Julia

Hacker News7
NP
NP-Food – Exact Cost37%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

NP-Food – Exact Cost

Hacker News24
TargetKB
TargetKB30%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Compress images to any exact KB or MB target

Indie Hackers