ashvardanian / SimSIMD

Up to 200x Faster Dot Products & Similarity Metrics — for Python, Rust, C, JS, and Swift, supporting f64, f32, f16 real & complex, i8, and bit vectors using SIMD for both AVX2, AVX-512, NEON, SVE, & SVE2 📐
https://ashvardanian.com/posts/simsimd-faster-scipy/
Apache License 2.0
988 stars 59 forks source link

Bug: segfault when calling `simsimd.cdist` without `metric=` keyword argument in Python #194

Closed fancidev closed 1 month ago

fancidev commented 1 month ago

Describe the bug

When calling simsimd.cdist passing the metric as a positional argument (instead of a keyword argument), a segfault is raised.

Steps to reproduce

import simsimd
import numpy as np

u = np.array([[-0.30039746, -0.13594460, 0.58292344]])
v = np.array([[-0.65563949, -0.29700866, 1.27146813]])

# simsimd.cdist(u, v, metric="sqeuclidean")  # ok
simsimd.cdist(u, v, "sqeuclidean")  # seg fault

Expected behavior

No segfault.

It seems to be a problem with how the Python binding is written rather than with the underlying algorithm.

SimSIMD version

5.4.3

Operating System

macOS Sonoma

Hardware architecture

Arm

Which interface are you using?

Python bindings

Contact Details

No response

Are you open to being tagged as a contributor?

Is there an existing issue for this?

Code of Conduct

ashvardanian commented 1 month ago

That's true, there is a SEGFAULT. I've noticed the issue yesterday, when sharing the benchmarks, will look into it. Thanks, @fancidev!