INNER CODE UNIT · Rust
target
RyanCodrai/turbovec · turbovec-python/src/lib.rs:402
let target = prev.saturating_add(prev / 2);
if snap.capacity() > target.saturating_mul(2) {
snap.truncate(target);
snap.shrink_to(target);
}
}
// `module` makes `__module__` report the extension module the class
// actually lives in, so a class reference round-trips through pickle and
// through any registry that records `f"{cls.__module__}.{cls.__name__}"`
// (it read `builtins.TurboQuantIndex` before, which resolves nowhere).
// `weakref` lets an index sit in a `weakref.WeakValueDictionary` — the
// standard way to key a per-tenant cache without pinning the memory
// (#340). Both classes carry the same options.
#[pyclass(frozen, module = "turbovec._turbovec", weakref)]
struct TurboQuantIndex {
/// Reusable GIL-safety snapshot buffer for `add`. Purely scratch:
/// contents are meaningless between calls; kept so repeated adds