FrankenNumPy

Docs/Context

FAQ

Is this a drop-in replacement for NumPy? Surface-wise yes: fnp-python exposes 100% of numpy.__all__ (499/499 names on the numpy<2.5 CI oracle), structurally locked by fnp_python_covers_full_numpy_all. Distribution-wise: pip install . from the checkout builds and installs a wheel (Linux / CPython 3.13 verified); there is no PyPI release yet. See Installation and Limitations.

How do you verify parity with NumPy? Oracle tests. We run the same operations with the same inputs in both NumPy and FrankenNumPy and compare outputs to floating-point tolerance. For RNG, the comparison is bit-exact. The G3 CI gate enforces FNP_REQUIRE_REAL_NUMPY_ORACLE=1, rejects pure-Python fallback oracle output, and checks the Rust engine (381 fixture cases through UFuncArray). The Python module is checked by the G2 conformance shards against live NumPy and by numpy's own test suite through scripts/run_numpy_dropin_suite.sh (a daily workflow, dropin.yml, outside the nine gates, and the release gate).

Why Rust nightly? Rust Edition 2024. The toolchain is pinned to nightly-2026-08-31 for reproducibility; see rust-toolchain.toml and the RUST_TOOLCHAIN env var in .github/workflows/ci.yml, which is the single source of truth for the CI gates.

Why zero unsafe code? Memory safety is a core value. 10 of the 11 implementation crates declare #![forbid(unsafe_code)] and contain zero hand-written unsafe. fnp-python is the one that doesn't: PyO3 procedural macros may expand into unsafe as part of generating the cdylib entry point, and the boundary crate has 67 audited unsafe blocks/items (encapsulating borrowed Python buffer views behind safe helpers, plus get_unchecked, transmute and target-feature functions in some kernels, and 3 unsafe extern "C" blocks declaring 35 glibc libm functions plus feclearexcept, fetestexcept, and dlsym), 100% documented with // SAFETY: comments. That unsafe is confined to fnp-python and structurally bounded by codebase_hygiene.rs, which also enforces that the numeric core stays unsafe-free.

How fast is it? The 2026-05-25 snapshot timed NumPy behind a passthrough for its winning rows and is not an engine measurement (see Performance). The three whole-job rows in docs/PERF_RELEASE_READINESS_SCORECARD.md, re-measured 2026-10-08 on thinkstation1 (release-perf, 4 threads, NumPy live in the same invocation, dual A/A nulls): int64 rolling-load 2.70-2.98x, float16 dynamic-range audit 3.87-4.50x and int64 critical-access 3.76-4.21x faster than NumPy; the families where NumPy has no fast path (f16, integer GEMM, hashed isin, string transforms) are where the large ratios live (see the Performance table). Plain float64 add/subtract below 8,192 elements and multiply/divide below 32,768 run a native loop; larger add/subtract/multiply run NumPy's loop, as does divide until 2^21 elements. Large dense square GEMM above roughly 2,000×2,000 remains slower than NumPy linked to OpenBLAS. Campaign wins require NumPy and FrankenNumPy end-to-end in the same invocation; within-FrankenNumPy self-speedups are maintenance results.

Can I use just the RNG crate? Yes. fnp-random keeps dependencies minimal (the required, dependency-free fnp-random-core, plus fnp-ndarray, getrandom for no-seed OS entropy, and rayon for data-parallel jump-ahead fills — those three optional, default-on features) and produces bit-exact NumPy-compatible random sequences from a given explicit seed.

What's the difference between fnp_python and just calling numpy? fnp_python is the parity oracle surface. Hot operations run native Rust kernels for the dtypes, layouts and sizes they cover; everything else falls back to numpy verbatim (including version-gated and deprecation paths). Behaviour matches NumPy except for the intentional divergences below and the drop-in suite's open divergences (47 of about 47,200 NumPy tests on 2026-10-08, each owned by a bead). You get one drop-in module, with Rust under the hood where it matters.

Is anything intentionally divergent from NumPy? Seven things, all recorded in docs/DIVERGENCES.md. Four are Hardened-mode only, with Strict matching NumPy: inf/NaN linalg operands raise LinAlgError, an array above the admission cap raises MemoryError, a load that violates an fnp-io bound raises ValueError, and SeedSequence.spawn refuses more than 4096 children. Two are FMA rounding contracts: native cov/corrcoef (only on the shapes where it is faster) and float64 einsum(optimize=False) accumulate without FMA, so they agree with NumPy to 1e-12 rather than bit for bit. One is a LAPACK contract: stacked (3-D and up) finite float64 inv / solve / pinv / eigvalsh / cholesky / svdvals / cond / matrix_rank / norm run fnp's own kernels inside their win gates and agree with NumPy within a stated norm-wise bound per lane rather than bit for bit. The ledger also carries two upstream NumPy defects fnp does not copy (float16 sort on AVX-512 with numpy 2.3.x; legacy RandomState.zipf never returning for a >= 1025). CI fails if a test tolerates a divergence the ledger does not name. No-seed RNG constructors source OS entropy via getrandom, matching NumPy.

Are there any stubs, TODOs, or mock code in production? No stubs or TODOs: the codebase_hygiene tests fail CI on TODO / FIXME / HACK / STUB / unimplemented!() / todo!() in library code. Panic sites do exist (30 .unwrap(), 48 .expect( plus 28 in the fnp-conformance harness, 20 unreachable! and 1 panic! outside tests as of 2026-10-08), mostly guarding internal invariants; see the Error Taxonomy section.

How do I find what changed recently? CHANGELOG.md is organized by capability area, with representative commit links and bead IDs. docs/planning/FEATURE_PARITY.md is the live parity matrix. docs/planning/audit_numpy_reality.md documents how the 100% surface coverage is maintained.


This section in the README on GitHub