https://github.com/libmir/mir.net
Mir Ref-Counted Type System for .NET
https://github.com/libmir/mir.net
datascience dotnet matrix types unmanaged-memory
Last synced: 11 months ago
JSON representation
Mir Ref-Counted Type System for .NET
- Host: GitHub
- URL: https://github.com/libmir/mir.net
- Owner: libmir
- Created: 2020-04-22T07:01:28.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-07-18T05:29:56.000Z (almost 3 years ago)
- Last Synced: 2025-05-20T09:56:58.927Z (about 1 year ago)
- Topics: datascience, dotnet, matrix, types, unmanaged-memory
- Language: C#
- Homepage:
- Size: 54.7 KB
- Stars: 8
- Watchers: 9
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mir.net
.NET Implementation of Mir Ref-Counted Type System (MTS)
### Features
- Fast generic types that are easy to construct, use, and pass between managed and unmanaged code.
- Faster than Protocol Buffers as well as any other serialization library because it is completely zero-copy.
- Requires around half the user code compared to Protocol Buffers.
- D and C++ implementations are provided via [Mir Algorithm](https://github.com/libmir/mir-algorithm/)
- D, C++, and C# MTS implementations are self-contained. C# implementation requires neither Mir Algorithm nor D/C/C++ runtimes.
- Hands-free. Just construct, pass, and forget. Mir objects hold all required information to destroy them and free memory.
The library is used in a large private codebase.
## [Install with NuGet](https://www.nuget.org/packages/Mir)
Or build NuGet package your self.
```sh
cd Mir
dotnet pack --configuration Release
```
## Basic Types
- Array
- Array slices
- Matrices
- Sorted dictionaries (`Series`)
- Slim shared pointers
- Shared Pointers with inheritance
- POD small strings
## Composed user-defined types
Mir types can be composed using other Mir types and C# POD types that don't require special marshaling. `MirWrapper` is a base class for all non-POD library and user-defined Mir types. It requires the structure payload (`Impl`) to be defined.
`MirPtr` and `MirSlimPtr` can be used to wrap a native type without defining its structure payload in C#.
## Table of correspondence
(check the source repository if the table isn't rendered correctly because of the [nuget issue](https://github.com/NuGet/NuGetGallery/issues/7035))
| D Type | C# Type | C++ Type |
|---|----|-----|
| [SlimRCPtr](http://mir-algorithm.libmir.org/mir_rc_slim_ptr.html)!Type | `MirSlimPtr` | `mir_slim_rcptr` |
| [RCPtr](http://mir-algorithm.libmir.org/mir_rc_ptr.html)!Type | `MirPtr` | `mir_rcptr` |
| [RCArray](http://mir-algorithm.libmir.org/mir_rc_array.html)!Type | `MirArray` ×2 | `mir_rcarray` |
| [Slice](http://mir-algorithm.libmir.org/mir_ndslice_slice.html)!([RCI](http://mir-algorithm.libmir.org/mir_rc_array.html#.mir_rci)!Type) | `Slice` ×2 | `mir_slice>` |
| [Slice](http://mir-algorithm.libmir.org/mir_ndslice_slice.html)!([RCI](http://mir-algorithm.libmir.org/mir_rc_array.html#.mir_rci)!Type, 2) | `Matrix` ×2 | `mir_slice, 2>` |
| [Slice](http://mir-algorithm.libmir.org/mir_ndslice_slice.html)!(Type*) | `SliceView` ×2 | `mir_slice` |
| [Series](http://mir-algorithm.libmir.org/mir_series.html)!([RCI](http://mir-algorithm.libmir.org/mir_rc_array.html#.mir_rci)!Key, [RCI](http://mir-algorithm.libmir.org/mir_rc_array.html#.mir_rci)!Value) | `Series` ×2 | `mir_series, mir_rci>` |
| [SmallString](http://mir-algorithm.libmir.org/mir_small_string.html)!N | `SmallStringN`, N=4,31,32,64,128 | `mir::SmallString` |
| [Series](http://mir-algorithm.libmir.org/mir_series.html)!([RCI](http://mir-algorithm.libmir.org/mir_rc_array.html#.mir_rci)!([RCArray](http://mir-algorithm.libmir.org/mir_rc_array.html)!(const char)), [RCI](http://mir-algorithm.libmir.org/mir_rc_array.html#.mir_rci)!Value) | `StringSeries` | `mir_series>, mir_rci>` |
`Name<... , @>` ×2 - means a type has two declarations, `Name<... >` and `Name<... , Impl>`, where `Impl`
is an unmanaged C# handle structure that describes non-POD Mir Type.
Composed Mir Type (CMT) is a type that is composed of CMT fields, library RefCounted fields, and POD structures and types.
Unmanaged C# handles should use `byte` instead of `bool`.