DotWrap 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DotWrap --version 0.1.0
                    
NuGet\Install-Package DotWrap -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotWrap" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotWrap" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="DotWrap" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DotWrap --version 0.1.0
                    
#r "nuget: DotWrap, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DotWrap@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DotWrap&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=DotWrap&version=0.1.0
                    
Install as a Cake Tool

DotWrap

Basic Usage

Suppose you have a c# class you want to call from Python:

using DotWrap;

namespace CoolCalc;

/// <summary>
/// A simple calculator class.
/// </summary>
[DotWrapExpose] // <-- mark with attr for source generator discoverablity
public class Calculator
{
    /// <summary>
    /// Adds two integers together.
    /// </summary>
    /// <param name="a">
    /// The first integer to add.
    /// </param>
    /// <param name="b">
    /// The second integer to add.
    /// </param>
    /// <returns>The sum of the two integers.</returns>
    public int Add(int a, int b) => a + b;
}

Next publish you package with

dotnet publish -r linux-x64 (or win-x64)

That is all! A complete python package will be created in a new directory called python-package-root. The package is fully annotated with the comments and type hints taken from the original c# methods to enable intellisense for package users

# main.py (auto generated by DotWrap)
class Calculator:
    """
    A simple calculator class.
    """
    def add(self, a: int, b: int) -> int:
        """
        Adds two integers together.

        :param a: The first integer to add.
        :param b: The second integer to add.
        :return: The sum of the two integers.
        """
        # implementation omitted for brevity

Use the following commands to test it locally

cd ./python-package-root
pip install .

From there you should be able to import your project and any exposed types.

import cool-calc

calc = cool-calc.Calculator()
result = calc.add(2, 3)
print(result)  # Output: 5

🚀 Performance

Why use DotWrap? One word: performance.

In a real-world benchmark summing all primes below 500,000:

<table> <tr> <th>Implementation</th> <th>Result</th> <th>Time</th> </tr> <tr> <td><strong>Python</strong></td> <td>9914236195</td> <td>0.98 s</td> </tr> <tr> <td><strong>C# (via DotWrap)</strong></td> <td>9914236195</td> <td>0.04 s</td> </tr> </table>

<p align="center"> <b>C# was <span style="color:#27ae60;">24x faster</span> than Python!</b> </p>

<details> <summary>See benchmark output</summary>

Benchmarking Python sum_of_primes...
Python sum_of_primes: 9914236195 (Time: 0.982828s)
Benchmarking c# sum_of_primes...
c# sum_of_primes: 9914236195 (Time: 0.040921s)
C# implementation is 24.02 times faster than Python.

</details>

If you need to accelerate performance-critical code, DotWrap makes it easy to harness the speed of C# from Python.

DotWrap is a package that automatically generates Python packages by wrapping AOT-compiled .NET libraries.


This project is licensed under the MIT License. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0 477 9/29/2025
0.2.3 122 9/26/2025
0.2.2 169 9/24/2025
0.2.1 117 8/23/2025
0.2.0 166 8/20/2025
0.1.2 165 8/19/2025
0.1.1 162 8/18/2025
0.1.0 136 8/17/2025
0.0.2 177 8/14/2025
0.0.1 174 8/12/2025