FrankenNumPy

NumPy in Rustv0.6.0PyPI and crates.io

NumPy, rebuilt in Rust. Same answers.

FrankenNumPy is a clean-room rewrite of NumPy in Rust. Swap one import and all 499 names in numpy.__all__ are there. Run NumPy’s own test suite with the swap made and 47,189 of the 47,236 tests that pass on NumPy still pass. Where NumPy has no fast path, such as float16 math, integer matrix multiply, string transforms and set membership, Rust kernels run up to 201 times faster and return NumPy’s exact bytes.

import numpy as npimport fnp_python as np

See the evidencepip install frankennumpy

Broadcast two arrays

fnp-ndarray and fnp-dtype answer

(4, 3) float64

Elements
12
A strides
(8, 0) bytes
B strides
(0, 8) bytes

Computed when you change an operand, by the crates compiled to WebAssembly.

Why it exists

A rewrite you can check against the original.

NumPy is the base of scientific Python, and about thirty years of C and Cython. Its behavior is defined by what it does rather than by a written contract, and its file parsers are C exposed to whatever file you open. FrankenNumPy treats NumPy as the specification: it reads the C for behavior, writes new Rust against it, and runs every answer back through a real NumPy.

  1. 01Read NumPy for behavior

    The C source is the specification: edge cases, error paths, promotion rules, RNG state. Nothing is translated line by line.

  2. 02Write it in safe Rust

    10 crates under #![forbid(unsafe_code)]. Shapes, dtypes and errors are types, and size arithmetic is checked.

  3. 03Run NumPy as the oracle

    The same inputs go through both. Shapes, dtypes and values are compared, bit for bit wherever NumPy is exact.

  4. 04Write down what differs

    A difference becomes a fix, a regression test or a row in the divergence ledger. CI rejects anything in between.

01Drop-in

One import, the whole NumPy surface.

import fnp_python as np answers to every name in numpy.__all__. Where FrankenNumPy has a Rust kernel for the dtype, layout and size you pass, the kernel runs; everywhere else the call goes to NumPy itself. Either way your code gets NumPy’s arrays, NumPy’s errors and NumPy’s warnings.

The surface

499 names, checked at every build.

A conformance test walks the live numpy.__all__ and fails CI if any name is missing. 333 of the names are FrankenNumPy’s own objects: Rust kernels with a NumPy fallback, native classes and overlay modules. The other 166 are NumPy’s own objects passed through unchanged, such as the scalar types and numpy.rec.

How coverage is locked

Find a name, or show only one kind of answer

NumPy 2.4.3source treeFrom the repository
499 of 499

Hover, focus or tap a name to see what answers it.

  • FrankenNumPy’s own object
  • NumPy’s own object
  • fn function uf ufunc ty scalar type cl class mod module obj object k constant
Names from NumPy 2.4.3 on Linux x86-64, the CI oracle; macOS builds of NumPy lack float128 and complex256. Which object answers each name was probed from a build of fnp_python at 65201f45d with fnp_python.<name> is numpy.<name>, using src/oracle/tiers.py.

NumPy’s own tests

NumPy’s test suite, run against fnp_python.

The drop-in harness runs 121 of NumPy’s test modules twice: once on NumPy, and once with fnp_python in NumPy’s place. On 2026-10-08, 47,236 tests passed on NumPy and 47,189 with the swap. Each of the 47 differences, in 10 modules, is owned by an open bead; an unowned one fails the daily run.

How the swap is made

Each tile is one NumPy test module, sized by its test count; hover for the counts

drop-in runMeasured data
  • Tests that pass with the swap
  • Tests that differ, a band at the foot of the tile
The swap replaces NumPy’s module-level functions and its linalg, fft, random and polynomial modules. Methods on an array (a.sum(), a.sort()) still run NumPy’s code, so tests that mostly call methods exercise fnp_python less. Modules with only a few tests are drawn at a small minimum size so they stay visible. Data: artifacts/dropin-numpy-suite-2026-10-08.json.

Under the import

Three ways a name gets answered.

Which of the three answers a name is fixed when the module loads, and the conformance shards pin both sides of every fast-path gate: the arguments that take the Rust kernel and the ones that fall through to NumPy.

The resolution model
  1. Tier 1A Rust kernel, with NumPy behind it

    A function such as np.sort, np.isin or np.matmul checks the dtype, layout, size and keyword arguments. If a native kernel covers them it runs; otherwise the call goes to numpy.sort itself, so anything the kernel does not cover behaves exactly as NumPy does.

    np.isin on float64 · np.matmul on float16 · np.strings.translate

  2. Tier 2A native class

    Objects that hold Rust state: np.random.Generator, SeedSequence and the five bit generators, np.nditer, and the r_ and c_ index objects.

    np.random.default_rng(12345) draws NumPy’s exact stream

  3. Tier 3NumPy’s own object

    Names whose meaning is pure NumPy state are bound to NumPy’s object itself, so fnp_python.rec is numpy.rec. There is no wrapper to drift out of date.

    the scalar types · np.rec · np.emath · np.s_

02Speed

Faster where NumPy has no fast path.

NumPy’s speed comes from BLAS and hand-tuned C loops for float32 and float64. float16 has no BLAS, integers have no BLAS, and string and set operations get generic loops. FrankenNumPy writes Rust kernels for those cases and times each one against NumPy in the same process, on the same operands, after checking that the outputs are equal.

Measured against NumPy

Up to 201× faster, with the same bytes out.

Each bar is one operation at one shape, timed in one process against NumPy’s own function: 15 interleaved rounds, the order reversed every other round, beside a NumPy-against-NumPy null. Every output was checked equal to NumPy’s before timing. The 6 cells with no win at that shape stay in the chart.

Benchmark method

Pick a family; hover a bar for both timings

perf scorecardMeasured data
Speedup is NumPy’s median time divided by FrankenNumPy’s. Host thinkstation1 (AMD Threadripper PRO 5975WX, 64 logical CPUs), NumPy 2.4.3, fnp_python built with --profile release-perf, default thread pools, 2026-10-08. The incumbent arm was asserted at run time to be NumPy’s own function. Data: artifacts/perf-scorecard-2026-10-08.json; every row has a matching entry in docs/NEGATIVE_EVIDENCE.md.

Every function

Where it is slower, too.

A sweep times all 292 functions FrankenNumPy implements itself, at 4,096 and 2^20 elements: 929 cells. 38% run more than 10% faster than NumPy, 54% land within 10% either way, and 69 are between 1.1× and 1.4× slower, mostly by a fraction of a microsecond of call overhead at 4,096 elements. 5 cells are more than 1.4× slower. The project publishes the whole map.

The loss map, explained

Each dot is one function at one size; find a function, or switch to one thread

loss mapMeasured data
Ratio is FrankenNumPy’s time over NumPy’s, the median of 7 interleaved rounds with a NumPy-against-NumPy null in each cell, on float64 and int64 operands chosen by probing each signature. A sweep cell is a lead to re-time, not a verdict: re-timed alone in fresh processes, the slowest 2^20 cells came in at 1.00 to 1.10×. With one thread, 8 cells are above 1.4×. Data: artifacts/loss-map-2026-10-08-pool.json and -serial.json.

Whole jobs

Three pipelines, start to finish.

Single calls can flatter a library. These three jobs chain several calls on realistic data, timed end to end against the same chain in NumPy at several sizes, with a null for each library. Every output matched NumPy byte for byte.

The release scorecard
  1. int64 counts, 2.2M to 8.8M

    Rolling-load saturation

    convolvemaximum.accumulateptp

    2.70–2.98× faster than NumPy

  2. float16 samples, 2M to 8M

    Dynamic-range audit

    frexpbincountldexp

    3.87–4.50× faster than NumPy

  3. int64, 4,096 to 16,384 accounts

    Critical-access exposure

    matmulmax / argmaxptp

    3.76–4.21× faster than NumPy

Release-perf build, four threads, 2026-10-08. Where FrankenNumPy does not try to win: square float64 matrix multiply against OpenBLAS. Its kernels skip fused multiply-add to keep results reproducible, and that costs speed at large sizes.

03Exact

Same seed, same bits.

A reproducible pipeline needs more than close answers. FrankenNumPy matches NumPy’s random streams bit for bit from an explicit seed, its type promotion pair for pair, and the bytes numpy.save writes. Each figure below computes FrankenNumPy’s side in your browser and compares it with NumPy’s, captured on the CI’s Linux oracle.

Random streams

12 draws, every bit compared.

Pick a bit generator, a seed and a distribution. fnp-random, compiled to WebAssembly, draws 12 values in this tab; NumPy 2.4.3 drew the same 12 when this page was built. Each row compares all 64 bits. Type your own seed and the page shows FrankenNumPy’s draws with the line of Python that checks them.

Determinism guarantees

Choose a generator, a seed and a distribution

fnp-randomNumPy 2.4.3Runs in your browser
Seed

NumPy’s values were captured on Linux x86-64 with NumPy 2.4.3 by src/oracle/capture.py. Draws that use only the bit stream and IEEE arithmetic match on any machine. von Mises and Laplace also call cos, exp or log; in this page those come from WebAssembly’s math library instead of glibc, so 8 of the 360 von Mises draws captured here differ from NumPy’s by 4 to 160 units in the last place, and 1 of the 360 Laplace draws by one. Native fnp_python on Linux calls glibc’s, as NumPy does.

Type promotion

196 dtype pairs, one answer each.

promote is a const fn with an explicit arm for every pair of its 18 dtypes, so a new dtype without promotion rules does not compile. The table is computed by fnp-dtype in this tab and checked against numpy.result_type. Hover a cell for the rule behind it.

The dtype system

Hover or tap a cell: the row’s dtype combined with the column’s

fnp-dtypeNumPy 2.4.3Runs in your browser
  • bool
  • signed
  • unsigned
  • float
  • complex

Names give bit widths, as in Rust: i8 is int8, u64 is uint64, c128 is complex128.

Only the 14 numeric dtypes are shown; strings, datetimes and structured dtypes promote within their own family. The table is symmetric, and uint64 with any signed integer gives float64: NumPy has no integer type that holds both 2^64 − 1 and negative numbers.

.npy files

The same file, byte for byte.

fnp-io writes the .npy format itself: the magic string, the version, a header dictionary padded to a multiple of 64 bytes, then the payload. Pick a dtype, a shape and an order. The file below is written in your browser, and every byte is compared with what numpy.save wrote.

I/O formats

Pick a dtype, a shape and a memory order

fnp-ioNumPy 2.4.3Runs in your browser
The 80 combinations here were saved with numpy.save on the oracle when this page was built. The array holds the values in the header’s descr type; a Fortran-ordered array is written column by column, as NumPy writes it.

04Hardened

Hostile input gets a named refusal.

File parsers are where memory bugs live. fnp-io is safe Rust with fixed budgets (a 64 KiB header, rank 32, 4,096 archive members, 2 GiB decoded) that it checks before allocating, and the workspace runs 42 fuzz targets across 8 fuzz crates. Every refusal carries a stable reason code. From Python, hardened mode puts the same checks in front of every load.

Crafted files

Ten files built to break a parser.

Each file below is real bytes. fnp-io reads it in your browser; NumPy’s outcome for the same bytes was recorded when this page was built. On the overflowing shape, NumPy’s element count wraps around to 12,884,901,887 and it asks for 96 GiB.

The threat model

Pick a file: the highlighted bytes are the ones each reader has to judge

fnp-ioNumPy 2.4.3Runs in your browser
The files are built by src/oracle/capture.py, which also records what numpy.load(..., allow_pickle=False) does with each one on NumPy 2.4.3. fnp-io’s verdict comes from fnp_io::load_auto, compiled to a 32-bit WebAssembly target here; on a 64-bit machine the same checks run with 64-bit sizes.

Strict and hardened

NumPy’s behavior by default, guards when you ask.

Strict mode, the default, matches NumPy. FNP_RUNTIME_MODE=hardened, or fnp_python.set_runtime_mode("hardened"), adds four guards. Each is a row in the divergence ledger, and each decision is recorded in a bounded ledger that get_runtime_decisions() returns.

The dual-mode runtime

Switch modes and compare what each call does

DIVERGENCES.mdWorked example

  1. np.linalg.solve(A, b) # A holds a NaNDIV-HARDENED-LINALG-NONFINITE

    StrictNumPy’s answer, unchecked: a NaN-filled result with a RuntimeWarning.

  2. np.zeros(10**10) # 80 GB of float64DIV-HARDENED-ADMISSION-CAP

    StrictNumPy asks the OS for the memory. Under Linux overcommit it usually gets it, and the process dies later when the pages are touched.

  3. np.load("crafted.npy") # 2^40 elements declared, 16 bytes storedDIV-HARDENED-LOAD-BOUNDS

    StrictNumPy reads the header and allocates the declared array before reading the payload: an 8 TiB request.

  4. np.random.SeedSequence(0).spawn(10_000)DIV-HARDENED-SPAWN-BUDGET

    Strict10,000 child seed sequences, exactly as NumPy spawns them.

Outcomes and messages as docs/DIVERGENCES.md records them; the admission cap is 4 GiB unless FNP_HARDENED_MAX_ARRAY_BYTES sets another. An unknown value in FNP_RUNTIME_MODE fails the import rather than guessing.

Memory safety

Unsafe code lives in one crate.

10 of the 11 crates declare #![forbid(unsafe_code)]. fnp-python, the PyO3 boundary that reads NumPy’s buffers without copying them, holds the rest: 67 audited unsafe blocks and items, each with a SAFETY comment, under a ceiling that a hygiene test enforces in CI.

The security model

Each bar is one crate, as long as its source; hover for its numbers

source treeREADMEFrom the repository

  • #![forbid(unsafe_code)]
  • The PyO3 boundary: audited unsafe

Bar length is the square root of the line count, so the smallest crates stay visible.

Lines counted from each crate’s src/, and #[test] functions from its src/ and tests/, when this page was built; fnp-python has 208,494 lines. The count of 67 unsafe blocks and items is the README’s, locked by fnp_python_unsafe_blocks_are_encapsulated_and_documented in crates/fnp-conformance/tests/codebase_hygiene.rs.

05Proof

Checked against NumPy, four different ways.

A test that compares with NumPy cannot catch a bug NumPy shares, and a stored expected value cannot tell a correct change from a plausible wrong one. FrankenNumPy layers differential, metamorphic, adversarial and witness tests so each covers what the others miss, then runs nine gates before a release is tagged.

Four layers

Plant a bug, see what catches it.

Each layer is blind to something. The differential layer trusts NumPy, the metamorphic layer only knows identities, the adversarial layer only looks for crashes, and witnesses only notice change. A bug has to get past all four.

Conformance methodology

Choose a bug to plant

READMEWorked example
  1. Differential

    Run the same input through NumPy and FrankenNumPy; compare shape, dtype and value.

  2. Metamorphic

    Check identities that hold for any input: a + b == b + a, sum(a) == sum(sort(a)), ifft(fft(x)) ≈ x.

  3. Adversarial

    Feed hostile input: NaN-filled arrays, shapes near usize::MAX, malformed headers, plus coverage-guided fuzzing.

  4. Witness

    Pin exact outputs, such as the first draws of each distribution from a fixed seed, so any change shows up as a diff.

The mapping is the README’s: a bug NumPy shares passes the differential layer and fails the metamorphic one; a plausible wrong value fails the differential layer; a crash fails the adversarial layer; a shifted random stream fails the witnesses. Behind them: 9,976 #[test] functions and 42 fuzz targets.

Nine gates

From formatting to the installed wheel.

The gates run from cheapest to heaviest, and a failure stops everything after it. A release is tagged only after scripts/release_gate.sh confirms all nine passed for that exact commit and NumPy’s own test suite passed through an fnp_python built from it.

CI gate topology
  1. G1fmt + lint

    cargo fmt --check, cargo check and cargo clippy -D warnings across the workspace

  2. G2unit + property

    every #[test] in the workspace, including the 194 fnp_python parity shards against live NumPy

  3. G3oracle differential

    captures NumPy’s answers and runs 381 fixture cases through the Rust engine; a pure-Python stand-in for NumPy is refused

  4. G4adversarial + security

    the threat-matrix scenarios against the parser, I/O and shape-validation boundaries

  5. G5test contract

    every test logs the fields the contract requires: fixture, seed, mode, environment, artifacts, reason code

  6. G6workflow forensics

    multi-step user workflows replayed end to end, with no retries and no flake budget

  7. G7performance budget

    this commit against its parent on the same runner; a decidable median regression above 7% fails

  8. G8durability + decode

    RaptorQ sidecars for the evidence bundles: drop a symbol, decode, and match the SHA-256

  9. G9wheel

    builds the Python wheel, installs it, and checks the installed package exposes the whole module

G1 to G8 also run locally in order with scripts/e2e/run_ci_gate_topology.sh. G3 checks the Rust engine against NumPy; the Python module is checked by the parity shards in G2 and by NumPy’s own test suite.

The divergence ledger

Every difference, written down.

10 rows as of 2026-11-22. 7 are deliberate: four apply only in hardened mode, and three are last-bit rounding contracts where NumPy’s BLAS fuses multiply-adds and FrankenNumPy does not. 3 are NumPy bugs FrankenNumPy declines to copy. A test that tolerates a difference from NumPy must cite a row, or CI fails.

Divergence ledger

Open a row for what NumPy does, and what each mode does

DIVERGENCES.mdFrom the repository
DIV-HARDENED-LINALG-NONFINITEDeliberateAn operand containing inf or NaN
Where
fnp_python.linalg svd, qr, cholesky, lstsq, solve, inv, det, slogdet, eigh, eigvals, eigvalsh, eig, pinv, matrix_rank (and their top-level aliases)
NumPy
NumPy answers inconsistently: svd / pinv raise LinAlgError("SVD did not converge"), inv / solve / det / slogdet return NaN-filled results with a RuntimeWarning, an inf-only matrix can yield a finite pinv
Strict mode
NumPy-identical: no check is made, NumPy's outcome is returned
Hardened mode
raises LinAlgError("OP: array must not contain infs or NaNs (hardened mode)") before any work and records a linalg_nonfinite_operand / full_validate runtime decision
DIV-HARDENED-ADMISSION-CAPDeliberateOne requested array larger than the hardened admission cap
Where
fnp_python creation routines empty, zeros, ones, full, zeros_like / ones_like / full_like (with shape=), eye, identity, tri, arange, linspace, logspace, geomspace, indices, repeat, tile, resize
NumPy
NumPy attempts the allocation and raises MemoryError only if the OS refuses it; under Linux overcommit a large empty / zeros usually succeeds and the process dies later, when its pages are touched
Strict mode
NumPy-identical: no check is made
Hardened mode
raises MemoryError("OP: requested array of N bytes exceeds the hardened admission cap of M bytes (FNP_HARDENED_MAX_ARRAY_BYTES)") before allocating and records an admission_cap_exceeded / full_validate runtime decision; spec section 16 ("Shape bomb": hardened enforces stricter admission caps)
DIV-HARDENED-LOAD-BOUNDSDeliberateA file that violates an fnp-io bound
Where
fnp_python.load of .npy and .npz, from a path or a file-like object, with or without mmap_mode
NumPy
NumPy reads the header with its own parser and ALLOCATES THE DECLARED ARRAY BEFORE READING THE PAYLOAD (a 16-byte payload under a 2^40-element header asks for 8 TiB); its zipfile reader opens any member count and inflates any declared size
Strict mode
NumPy-identical: no check is made (a path .npy still decodes natively, but anything its header cannot promise is NumPy's)
Hardened mode
raises ValueError("load: refused by the hardened fnp-io bounds (REASON): DETAIL") before NumPy sees the bytes and records a runtime decision under fnp-io's reason code (io_header_schema_invalid, io_read_payload_incomplete, io_npz_archive_contract_violation, ...) / full_validate; a pickle or any non-npy/npz file stays NumPy's
DIV-HARDENED-SPAWN-BUDGETDeliberateMore than 4096 children in one spawn call
Where
fnp_python.random SeedSequence.spawn, and every bit generator's spawn (which calls it)
NumPy
NumPy spawns any count (its loop index is a uint32_t)
Strict mode
NumPy-identical: the children, spawn keys and draws numpy produces (the packet-007 cap applied in every mode until deadlock-audit-r8eqg)
Hardened mode
raises ValueError("SeedSequence.spawn(N): more than 4096 children per call exceeds the hardened spawn budget (packet-007)") and records an rng_seedsequence_spawn_contract_violation / full_validate runtime decision - the cap artifacts/phase2c/FNP-P2C-007/risk_note.md lists under "Explicit bounded caps (hardened policy path)"
DIV-COV-GRAM-NO-FMADeliberateEntries can differ from NumPy in the last bits
Where
fnp_python cov / corrcoef native Gram path (contiguous float64, and integer inputs, which numpy and fnp both compute in float64), engaged only where it beats numpy: small Gram work (n_vars < 48), 256 <= n_vars < 512 with n_obs >= 2048, and n_vars >= 512 only when numpy's BLAS is serial; every other shape is numpy's and byte-identical
NumPy
NumPy computes dot(X, X.T) through BLAS dgemm, whose micro-kernels are FMA-contracted and chosen by shape, so NumPy's own bytes vary with shape and BLAS build
Strict mode
fnp accumulates without FMA, the workspace-wide bit-reproducibility rule; results are equal within the bounds above
Hardened mode
same as strict
DIV-BATCHED-LINALG-NO-LAPACKDeliberateValues can differ from NumPy in the last bits, within a norm-wise bound per lane (C = 32)
Where
fnp_python.linalg on a finite float64 STACK (ndim >= 3, ndarray or nested list) inside each route's measured win gate: inv (n < 16, or batch < 256), solve (batch >= 1024, or >= 256 with n <= 4, or a broadcast A), eigvalsh (n <= 6, or >= 2^18 elements), cholesky (n <= 3), pinv (n <= 24, or >= 2^18 elements), svdvals / cond / matrix_rank / norm and matrix_norm with ord 2, -2 or 'nuc' (n <= 8, or >= 2^18 elements)
NumPy
NumPy loops LAPACK per lane (getrf/getri, gesv, syevd, potrf, gesdd), whose blocked, FMA-contracted operation order depends on the BLAS build
Strict mode
fnp's per-lane kernels factor in their own order without FMA (the workspace bit-reproducibility rule), in parallel across lanes; det, slogdet, eigh, tensorinv and non-finite stacks are NumPy's (their native kernels returned wrong answers, bead deadlock-audit-41n96)
Hardened mode
same as strict
DIV-EINSUM-FLOAT-NO-FMADeliberateThe value can differ from NumPy in the last bits
Where
fnp_python einsum with optimize=False and a float64 result, two or more operands with a summed index (matrix-product, dot, row-dot and transposed-product spellings); and np.matvec / np.vecmat of a float64 2-D matrix and 1-D vector, which run the same contraction kernel (bead deadlock-audit-6y5wp; found unledgered 2026-10-08)
NumPy
NumPy's einsum inner loops (sum_of_products_* in einsum_sumprod.c.src) accumulate with npyv_muladd - FMA-contracted, in lanes whose count follows the host ISA
Strict mode
fnp contracts without FMA, the workspace-wide bit-reproducibility rule. A float32 or complex result is NumPy's own call (float32 was computed in float64 and rounded once until bead deadlock-audit-vc4p4); optimize=True calls, integer / bool / float16 / float32 / complex operands and every other product function (matmul, dot, inner, vdot, tensordot, kron, trace) are byte-identical to NumPy
Hardened mode
same as strict
UD-F16-SORT-X86SIMDSORTNumPy bug, not copiedfnp returns ascending output where NumPy does not
Where
fnp_python sort / unique on float16
NumPy
numpy 2.3.x on AVX-512 hosts: the x86-simd-sort fp16 qsort emits non-ascending output (observed on hz2; fleet workers on numpy 2.4.3 are clean)
Strict mode
fnp output is correctly sorted and byte-equal to NumPy's own float32-widened sort; on hosts without the defect it is byte-equal to NumPy directly
Hardened mode
same as strict
UD-LEGACY-ZIPF-LARGE-ANumPy bug, not copieda >= 1025, inf included
Where
fnp_python.random.RandomState.zipf, scalar and array a
NumPy
numpy's legacy_random_zipf (installed 2.4.3 and the vendored source) never returns there: b = 2**(a - 1) overflows, every candidate is 1 and its acceptance test is NaN, so the call spins until the process is killed
Strict mode
1 for each such entry, without a draw, as numpy's modern random_zipf answers the same a (its guard notes the chance of a value above 1 is below 3e-309); below 1025 the draws are numpy's legacy draws byte for byte
Hardened mode
same as strict
UD-GEOMETRIC-SEARCH-STALLNumPy bug, not copiedp >= 1/3 when the rounded CDF sum stops increasing below the drawn uniform
Where
fnp-random and fnp_python.random Generator / RandomState geometric, scalar and array p
NumPy
NumPy 2.3.5 and the vendored search loop never return: all subsequent positive terms are smaller and cannot increase the sum; maximum-uniform reproductions at p=0.33333666666666667 and p=0.38687720490923644 timed out in isolated processes
Strict mode
returns the index of the first stalled term (91 and 76 in the reproductions), consuming the same single uniform; this is a termination bound, not a general exact-quantile claim; every terminating NumPy search retains its result and stream position
Hardened mode
same as strict
Read from docs/DIVERGENCES.md when this page was built. repository_markers_and_ledger_rows_agree runs in CI G2: it fails when an ignored test or expected failure cites no live row, or when a row’s probe test no longer exists.

06Rust

NumPy’s rules, as Rust crates.

The engine under fnp_python is eleven crates on crates.io. From Rust they need no Python and no C: read and write .npy files with bounded parsing, draw the same random streams NumPy draws, or apply NumPy’s broadcasting and promotion rules in your own code. The engine running this page is four of them.

The crates

11 crates, one job each.

467,200 lines of Rust, 1,931 public functions and 9,976 tests, edition 2024 on the pinned nightly-2026-08-31 toolchain. Each crate depends only on the ones below it, and fnp-conformance tests all of them against NumPy.

Workspace and crate map

Pick a crate for what it does and how to add it

source treeFrom the repository
Counted from the repository when this page was built; the lines are each crate’s src/. Arrows are the fnp crates each manifest depends on. All 11 crates are published to crates.io with each tagged release.

In code

NumPy’s answers, from a Rust binary.

Four short examples, one per job. Each compiles against the published crates; the README’s cookbook has longer ones.

Cookbook

fnp-random

use fnp_random::{BitGenerator, BitGeneratorKind, Generator, SeedSequence};

// The stream numpy.random.Generator(numpy.random.PCG64DXSM(12345)) draws
let mut rng = Generator::from_pcg64_dxsm(12345)?;
let normals = rng.standard_normal(1000);
let counts = rng.binomial(10, 0.5, 100)?;          // BTPE, as NumPy samples it

// Eight independent, reproducible streams for eight workers
let mut root = SeedSequence::new(&[42])?;
for child in root.spawn(8)? {
    let bits = BitGenerator::from_seed_sequence(BitGeneratorKind::Pcg64Dxsm, &child)?;
    let mut worker = Generator::from_bit_generator(bits);
    let _sample = worker.standard_normal(10_000);
}

Other Rust array crates

When to use something else.

FrankenNumPy is the crate to reach for when you need the answer NumPy would give: its promotion table, its broadcasting, its random streams, its .npy bytes. For other jobs these are better choices.

Comparison
CrateWhat it isUse it instead when
ndarrayThe standard Rust n-dimensional array, generic over element type and rank, with BLAS through ndarray-linalg.You are writing new Rust that does not need NumPy’s semantics, and want compile-time dimensionality.
nalgebraLinear algebra with statically sized vectors and matrices, strong on geometry and robotics.Your shapes are small and known at compile time.
polarsAn Arrow-backed DataFrame engine.Your data is tables to join and group, not arrays to compute on.
burn, candleDeep-learning tensors with autodiff and GPU backends.You need gradients or a GPU; their shape and dtype rules differ from NumPy’s on purpose.

v0.6.0, open source

Try it on your own code.

Python wheels are on PyPI for Linux on x86-64 and aarch64, CPython 3.13 and 3.14; other platforms build from source with the pinned nightly Rust toolchain. The eleven crates are on crates.io. Run your test suite with the import swapped, and compare.

Python

Needs CPython 3.13 or newer and NumPy 2.3 or newer, which fnp_python calls for everything it has no native route for.

# Linux wheels; elsewhere pip builds from the source distribution
pip install frankennumpy

import fnp_python as np
rng = np.random.default_rng(12345)
rng.standard_normal(5)   # NumPy's exact stream

Rust

Pure Rust, no Python and no C. Take only what you need: the random streams, the .npy reader, or the whole array engine.

# NumPy-identical random streams and bounded .npy I/O
cargo add fnp-random fnp-io

let mut rng = fnp_random::Generator::from_pcg64_dxsm(12345)?;
let x = rng.standard_normal(5);   // same bits as NumPy

What it does not do yet

  • Square float64 matrix multiply above about 2,000 × 2,000 is slower than NumPy linked to OpenBLAS. The Rust kernels avoid fused multiply-add so that results reproduce exactly.
  • Methods on an array, such as a.sum(), are NumPy’s own. The native kernels sit behind the module-level functions, np.sum(a).
  • PyPI has Linux wheels only. macOS and Windows install from source, which needs the nightly Rust toolchain the project pins.
  • fnp_python works on NumPy’s own ndarray and needs NumPy installed. A standalone array object is on the roadmap.
  • No GPU and no autodiff. CuPy, JAX and PyTorch cover those, and FrankenNumPy does not plan to.
  • The Rust API is 0.x: crate interfaces will change before 1.0. The NumPy-facing behavior is the stable part.

Bug reports are welcome as GitHub issues. The project does not merge outside pull requests; fixes are made in-house, which the README explains.