CSnakes.Runtime
1.2.1
See the version list below for details.
dotnet add package CSnakes.Runtime --version 1.2.1
NuGet\Install-Package CSnakes.Runtime -Version 1.2.1
<PackageReference Include="CSnakes.Runtime" Version="1.2.1" />
<PackageVersion Include="CSnakes.Runtime" Version="1.2.1" />
<PackageReference Include="CSnakes.Runtime" />
paket add CSnakes.Runtime --version 1.2.1
#r "nuget: CSnakes.Runtime, 1.2.1"
#:package CSnakes.Runtime@1.2.1
#addin nuget:?package=CSnakes.Runtime&version=1.2.1
#tool nuget:?package=CSnakes.Runtime&version=1.2.1
CSnakes - a tool for embedding Python code into .NET projects
<img src="docs/res/logo.jpeg" alt="drawing" width="200"/>
CSnakes is a .NET Source Generator and Runtime that you can use to embed Python code and libraries into your C#.NET Solution at a performant, low-level without the need for REST, HTTP, or Microservices.
Check out the getting started guide or check out the demo solution to see more.
Features
- ๐ค Supports .NET 8 and 9
- ๐ Supports Python 3.9-3.13
- ๐ฆ Supports Virtual Environments and C-Extensions
- ๐ป Supports Windows, macOS, and Linux
- ๐งฎ Tight integration between NumPy ndarrays and Spans, 2D Spans and TensorSpans (.NET 9)
- โก Uses Python's C-API for fast invocation of Python code directly in the .NET process
- ๐ง Uses Python type hinting to generate function signatures with .NET native types
- ๐งต Supports CPython 3.13 "free-threading" mode
- ๐งฉ Supports nested sequence and mapping types (
tuple,dict,list) - ๐ท๏ธ Supports default values
- ๐ฅ Supports Hot Reload of Python code in Visual Studio and supported IDEs
- ๐ Supports UV for fast installation of Python packages and dependencies
Benefits
- Uses native Python type hinting standards to produce clean, readable C# code with minimal boiler plate!
- Integration between .NET and Python is done at the C-API, meaning strong compatibility between Python versions 3.8-3.13 and .NET 8-9.
- Integration is low-level and high-performance.
- CSnakes uses the CPython C-API and is compatible with all Python extensions.
- Invocation of Python code and libraries is in the same process as .NET
<br />
Click to watch the CSnakes demo video on YouTube
<br />
Example
CSnakes will generate a C#.NET class for any Python file in a project that is tagged as CSharp Analyzer Additional File (see Getting Started). All functions in that class with type annotations will be reflected to callable C# methods and an environment builder added to that module.
Given the following Python file called example.py
def hello_world(name: str, age: int) -> str:
return f"Hello {name}, you must be {age} years old!"
CSnakes will generate a static .NET class called Example with the function:
public class Example {
public static string HelloWorld(string name, long age) {
...
}
}
When called, HelloWorld() will invoke the Python function from example.py using Python's C-API and return native .NET types.
FAQ
See the FAQ for more information.
| Product | Versions 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 was computed. 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. |
-
net8.0
- CommunityToolkit.HighPerformance (>= 8.4.0)
- Microsoft.Extensions.Hosting (>= 9.0.7)
- ZstdSharp.Port (>= 0.8.6)
-
net9.0
- CommunityToolkit.HighPerformance (>= 8.4.0)
- Microsoft.Extensions.Hosting (>= 9.0.7)
- System.Numerics.Tensors (>= 9.0.7)
- ZstdSharp.Port (>= 0.8.6)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on CSnakes.Runtime:
| Package | Downloads |
|---|---|
|
Glidergun
Package Description |
|
|
Harbour.NETCore.CSnakes
Harbour.NETCore.CSnakes |
|
|
Evergine.Runtimes.USD
Package Description |
|
|
TransformersSharp
Package Description |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on CSnakes.Runtime:
| Repository | Stars |
|---|---|
|
tonybaloney/TransformersSharp
A little wrapper for hugging face transformers in C#
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0-beta.323 | 114 | 2/8/2026 |
| 2.0.0-beta.322 | 37 | 2/6/2026 |
| 2.0.0-beta.321 | 28 | 2/6/2026 |
| 2.0.0-beta.320 | 79 | 2/5/2026 |
| 2.0.0-beta.319 | 487 | 1/14/2026 |
| 2.0.0-beta.318 | 255 | 1/5/2026 |
| 2.0.0-beta.317 | 57 | 12/31/2025 |
| 2.0.0-beta.316 | 46 | 12/31/2025 |
| 2.0.0-beta.315 | 49 | 12/30/2025 |
| 2.0.0-beta.314 | 53 | 12/27/2025 |
| 2.0.0-beta.313 | 213 | 12/22/2025 |
| 2.0.0-beta.312 | 167 | 12/21/2025 |
| 2.0.0-beta.311 | 134 | 12/21/2025 |
| 2.0.0-beta.310 | 123 | 12/21/2025 |
| 2.0.0-beta.309 | 163 | 12/19/2025 |
| 2.0.0-beta.308 | 200 | 12/19/2025 |
| 2.0.0-beta.307 | 201 | 12/19/2025 |
| 2.0.0-beta.306 | 274 | 12/17/2025 |
| 2.0.0-beta.305 | 250 | 12/14/2025 |
| 1.2.1 | 36,331 | 8/8/2025 |