Nuwa SDK
Python interoperability utilities for building high-performance Python extensions with Nim.
Overview
Nuwa SDK provides core utilities for Nim/Python interop when building extensions with Nuwa Build.
Features
nuwa_export- Macro for automatic generation of Python type stubs (.pyifiles)withNogil- Template for releasing the Python GIL during pure Nim code executionasNumpyArray- Zero-copy views of existing NumPy / PEP 3118 buffers (does not allocate ndarrays)
Installation
Nuwa SDK is automatically installed when you create a new project with nuwa new.
Manual installation:
nimble install nuwa_sdk
Quick Start
import nuwa_sdk
proc add(a: int, b: int): int {.nuwa_export.} =
## Add two integers together
return a + b
proc greet(name: string): string {.nuwa_export.} =
## Greet a person by name
return "Hello, " & name
When you build with nuwa develop or nuwa build, the macro:
1. Exports the function to Python (via nimpy)
2. Writes compile-time metadata (JSON under nuwaStubDir, or NUWA_STUB: on stdout)
3. Lets nuwa-build generate .pyi stub files
Next Steps
- nuwa_export Macro - Automatic type stub generation
- GIL Release - Parallel execution with withNogil
- NumPy buffers - Zero-copy views of existing arrays
- Type Mappings - Nim to Python type conversions