NumPy for the .NET crowd: copy-paste and pray less
A C# port of NumPy that tries to make translating Python ML code feel like a search-and-replace exercise.

What it does
NumSharp is a native C# implementation of NumPy-style N-dimensional arrays for .NET Standard. It gives you np.arange, slicing, broadcasting, reshaping, and the rest of the tensor basics without leaving the CLR. The pitch is straightforward: keep function names and parameter positions identical to NumPy so you can port Python ML code with minimal friction.
The interesting bit
The project leans hard into performance theater—unmanaged memory, unsafe algorithms, and “almost non-effort copy-pasting”—yet the README also admits to 150,000 lines of generated code via a custom templating engine called Regen. That’s either admirably obsessive or a maintenance haiku, depending on your tolerance for #if _REGEN blocks.
Key highlights
- Slicing supports nested/recursive string syntax like
nd["-1, ::2"]["1::3, :, 0"] - Broadcasting and axis iteration across implemented functions
- Views over copies where possible, matching NumPy’s memory model
System.Drawing.Bitmapextensions for image pipeline interop- Referenced by ML.NET, TensorFlow.NET, and other SciSharp ecosystem projects
Caveats
- The README claims “fast unsafe algorithms” but offers no actual benchmark numbers to inspect
- “Almost non-effort copy-pasting” is doing a lot of heavy lifting—edge cases in type resolution and C#-Python semantic gaps aren’t explored
- Sister project Numpy.NET (using pythonnet) exists for when you need “more whole implementation”
Verdict Worth a look if you’re committed to .NET and need NumPy-like ergonomics without a Python runtime. If you need the actual NumPy ecosystem—SciPy, scikit-learn, mature linear algebra—this is a bridge, not a destination.