INNER CODE UNIT · Rust
new
RyanCodrai/turbovec · turbovec-python/src/lib.rs:442
fn new(dim: Option<&Bound<'_, PyAny>>, bit_width: Option<&Bound<'_, PyAny>>) -> PyResult<Self> {
let bit_width = match bit_width {
Some(b) => extract_size("bit_width", b)?,
None => 4,
};
let inner = match dim {
Some(d) => turbovec_core::TurboQuantIndex::new(extract_size("dim", d)?, bit_width),
None => turbovec_core::TurboQuantIndex::new_lazy(bit_width),
}
.map_err(|e| pyo3::exceptions::PyValueError::new_err(e.to_string()))?;
Ok(Self {
inner: std::sync::RwLock::new(inner),
snap: std::sync::Mutex::new(Vec::new()),
snap_prev: std::sync::atomic::AtomicUsize::new(0),
})
}
fn add(&self, py: Python<'_>, vectors: &Bound<'_, PyAny>) -> PyResult<()> {