Skip to content

Commit 50087f4

Browse files
authored
Update README.md
1 parent 38bf6c4 commit 50087f4

1 file changed

Lines changed: 55 additions & 1 deletion

File tree

README.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,56 @@
11
# Numpy.NET
2-
C# bindings for NumPy - a fundamental library for scientific computing, machine learning and AI
2+
Numpy.NET brings the awesome Python package [NumPy](https://www.numpy.org/) to the .NET world. NumPy is THE fundamental library for scientific computing, machine learning and AI in Python. Numpy.NET empowers .NET developers to leverage NumPy's extensive functionality including multi-dimensional arrays and matrices, linear algebra, FFT and many more via a compatible strong typed API.
3+
4+
## Example
5+
6+
## How does it work?
7+
8+
Numpy.NET uses [Python for .NET](http://pythonnet.github.io/) to call into the Python module `numpy`. However, this does not mean that it depends on a local Python installation! Numpy.NET.dll uses [Python.Included](https://github.com/henon/Python.Included) which packages embedded Python 3.7 and automatically deploys it in the user's home directory upon first execution. On subsequent runs, it will find Python already deployed and therefor doesn't install it again. Numpy.NET also packages the NumPy wheel and installs it into the embedded Python installation when not yet installed.
9+
10+
Long story short: as a .NET Developer **you don't need to worry about Python** at all. You just reference Numpy.NET, use it and **it will just work**, no matter if you have local Python installations or not.
11+
12+
## Performance considerations
13+
14+
You might ask how calling into Python affects performance. As always, it depends on your usage. Don't forget that `numpy`'s number crunching algorithms are written in `C` so the thin `pythonnet` and `Python` layers on top won't have a significant impact if you are working with larger amounds of data.
15+
16+
All of `numpy` is centered around the `ndarray` class which allows you to pass a huge chunk of data into the `C` routines and let them execute all kinds of operations on them efficiently. So if you are manipulating arrays or matrices with thousands or hundreds of thousands of elements, the overhead will be neglegible.
17+
18+
*Array creation* actually has the most impact on performance since the data has to be moved from the `CLR` into the `Python` interpreter. `pythonnet` does not optimize for passing large arrays from `C#` to `Python` but we still found a way to do that very efficiently. When creating an array with `np.array( ... )` we internally use `Marshal.Copy` to copy the entiry `C#`-array's memory into the `numpy`-array's storage. And to efficiently retrieve computation results from `numpy` there is a method called `GetData<T>` which will copy the data back to `C#`.
19+
20+
## Numpy.NET vs NumSharp
21+
22+
The SciSharp team is also developing a pure C# port of NumPy called [NumSharp](https://github.com/SciSharp/NumSharp) which is quite popular albeit incomplete. To help you decide which one to use we compare the advantages and disadvantages of both libraries here:
23+
24+
| Aspect | Numpy.NET | NumSharp |
25+
| ------------- | ------------------------------------- | ------------- |
26+
| Dependencies | CPython / NumPy | C++ dlls for certain operations |
27+
| Setup | Reference Nuget-Package | Reference Nuget-Package |
28+
| Completeness | Large parts are wrapped | A small subset of most important functions is ported |
29+
| Development | Fast, due to automated API generation | Very slow, due to lack of manpower |
30+
| Correctness | Same results as in Python guaranteed | There are many subtle differences |
31+
| Actuality | Can easily keep up with `numpy` dev | Will always trail way behind, due to lack of manpower |
32+
| GPU support | None | Using a GPU backend for calculatons possible, per design |
33+
| Performance | TODO: measure | TODO: measure |
34+
35+
## Code generation
36+
37+
The vast majority of Numpy.NET's code is generated using [CodeMinion](https://github.com/SciSharp/CodeMinion) by parsing the documentation at [docs.scipy.org/doc/numpy/](docs.scipy.org/doc/numpy/). This allowed us to wrap most of the `numpy`-API in just two weeks. The rest of the API can be completed in a few more weeks if there is popular demand.
38+
39+
## API Completion
40+
41+
TODO: information about completed API categories
42+
43+
## Versions and Compatibility
44+
45+
Currently, Numpy.NET is targeting .NET Standard (on Windows) and packages the following binaries:
46+
* Python 3.7: (python-3.7.3-embed-amd64.zip)
47+
* NumPy 1.16 (numpy-1.16.3-cp37-cp37m-win_amd64.whl)
48+
49+
To make Numpy.NET support Linux a separate version of [Python.Included]() packaging linux binaries of Python needs to be made and a version of Numpy.NET that packages a linux-compatible NumPy wheel.
50+
51+
## License
52+
53+
Numpy.NET packages and distributes `Python`, `pythonnet` as well as `numpy`. All these dependencies imprint their license conditions upon Numpy.NET. The C# wrapper itself is MIT License.
54+
55+
56+

0 commit comments

Comments
 (0)