PyDotNet

A modern, high-performance, async-aware, zero-copy Python ↔ .NET interop runtime.

PyDotNet embeds CPython directly inside your .NET process. No subprocess, no sockets, no serialisation — just raw function calls across the language boundary with full GIL awareness and optional zero-copy memory sharing.

PyRuntime.Initialize();

using var interpreter = PyRuntime.CreateInterpreter();
using var math = interpreter.ImportModule("math");
using var result = math.Call("sqrt", 144.0);

Console.WriteLine(result.As<double>());   // 12

Where to start

API reference Every public type and member, generated from the source
Virtual environments and isolation Point PyDotNet at a venv; control what the interpreter can see
Async hosting Driving Python asyncio from .NET tasks in production
Exception handling Catching Python errors by type, and following their causes
Callbacks Passing .NET methods to Python as callables
Hosting and dependency injection AddPyDotNet, configuration binding, and the health check
Performance Benchmarks, and where the zero-copy paths apply
Observability OpenTelemetry traces and metrics

Plugin packages

Typed, idiomatic C# wrappers for popular Python libraries, built on the core runtime:

Package Guide
PyDotNet.NumPy NumPy
PyDotNet.DataFrames Pandas and Polars
PyDotNet.Torch PyTorch
PyDotNet.Matplotlib Matplotlib
PyDotNet.Extensions.Hosting Hosting and dependency injection

Supported versions

.NET 8, 9 and 10 · CPython 3.11 through 3.15, standard or free-threaded builds · Windows, Linux (x64 and arm64), macOS (Apple Silicon)

The full narrative documentation — installation, quick start, marshaling, buffers, DLPack, the async bridge and more — lives in the README.