numpy-ts 1.2 Hits 50% Native NumPy Performance With Float16 Support

numpy-ts 1.2 Hits 50% Native NumPy Performance With Float16 Support

lschvn

numpy-ts, the most comprehensive NumPy implementation built entirely in TypeScript, has released version 1.2 β€” and it marks the project's most significant performance milestone yet. The library now runs at approximately 50% of native NumPy performance, while adding first-class Float16 support for memory-efficient numerical workflows.

The project fills a gap the JavaScript ecosystem has long struggled with: running numerical and scientific computing code in the browser without falling back to native binaries or WebAssembly compilation steps.

What numpy-ts is trying to solve

Python's NumPy is the de facto standard for array-based computing β€” from linear algebra and signal processing to data preprocessing for machine learning. Bringing that API to JavaScript and TypeScript has obvious appeal for web-based tools, notebooks, and browser-native data science applications.

The challenge is that NumPy achieves its speed through highly optimized C and Fortran code under the hood (via BLAS and LAPACK). Pure JavaScript or TypeScript implementations have to work around the lack of low-level array primitives, which is why most previous attempts were either incomplete, slow, or required WebAssembly compilation pipelines.

numpy-ts takes a different approach: it implements the NumPy API as faithfully as possible in TypeScript, validating its output against the actual NumPy test suite to catch correctness bugs early. Version 1.2 pushes the performance envelope further by optimizing hot paths and adding SIMD-friendly data structures where the JavaScript engine allows.

Float16: the new dtype in town

Float16 (also called half-precision or float16) uses 16 bits per number instead of the standard 32 or 64. It's been a fixture of GPU computing for years β€” NVIDIA's Tensor Cores, for instance, operate natively on Float16 β€” because it dramatically reduces memory usage and memory bandwidth requirements during inference.

Until now, numpy-ts didn't support Float16, limiting its usefulness for ML-adjacent workflows. Version 1.2 adds it alongside full support for Float32, Float64, Int8/16/32, Uint8/16/32, and complex number types.

API compatibility with NumPy

The project's stated goal is API compatibility with NumPy, not just the concepts. The v1.2 documentation includes a NumPy Migration Guide that shows side-by-side Python and TypeScript examples. Most code translates directly:

import numpy as np

a = np.array([[1, 2], [3, 4]])
b = np.linalg.inv(a)
c = np.dot(a, b)
d = np.sum(a, axis=0)
import { array, linalg, dot, sum } from 'numpy-ts';

const a = array([[1, 2], [3, 4]]);
const b = linalg.inv(a);
const c = dot(a, b);
const d = sum(a, { axis: 0 });

This close mapping makes it practical to port NumPy-based preprocessing pipelines to TypeScript with minimal rewrite.

Where it fits in the JS/ML ecosystem

numpy-ts isn't competing with WebGPU-based ML libraries like JAX.js for training workloads. Instead, it targets the large set of numerical tasks that don't need GPU acceleration: data cleaning, statistical summaries, matrix operations for non-ML applications, and anywhere you want NumPy's API without a Python runtime.

At 94% API coverage, numpy-ts is also the most complete NumPy port in the JavaScript ecosystem. Other ports exist but trail significantly in breadth.

Getting started

npm install numpy-ts
# or
yarn add numpy-ts
# or
pnpm add numpy-ts

The library has no runtime dependencies and works in both Node.js (CommonJS and ESM) and modern browsers. Full documentation, the migration guide, and API reference are at numpyts.dev.

Frequently Asked Questions

Related articles

More coverage with overlapping topics and tags.

ESLint v10 Drops Legacy Config β€” And the JS Ecosystem Is Taking Notes
javascript

ESLint v10 Drops Legacy Config β€” And the JS Ecosystem Is Taking Notes

ESLint's biggest breaking-change release in years finalises flat config, removes eslintrc support entirely, and adds JSX reference tracking. But the bigger story might be what's nipping at its heels.
Oxc Is Quietly Building the Fastest JavaScript Toolchain in Rust β€” And It's Almost Ready
javascript

Oxc Is Quietly Building the Fastest JavaScript Toolchain in Rust β€” And It's Almost Ready

While ESLint v10 was wrestling with legacy cleanup, the Oxc project shipped a linter 100x faster, a formatter 30x faster than Prettier, and a parser that leaves SWC in the dust. Here's what the JavaScript oxidation compiler actually is.
Next.js 16.2 Stabilizes the Adapter API β€” and It's a Bigger Deal Than It Sounds
typescript

Next.js 16.2 Stabilizes the Adapter API β€” and It's a Bigger Deal Than It Sounds

Vercel, Netlify, Cloudflare, AWS, and Google Cloud all signed the same public contract. Next.js 16.2 makes cross-platform deployment a first-class, documented feature.

Comments

Log in Log in to join the conversation.

No comments yet. Be the first to share your thoughts.