Wyn vs Python
Wyn was designed for developers who like Python's syntax but need compiled performance. Both languages prioritize readability, but Wyn compiles to native binaries via C — no interpreter, no VM, no GIL.
Quick Facts
| Wyn | Python | |
|---|---|---|
| Type system | Static, inferred | Dynamic |
| Execution | Compiled to C → native binary | Interpreted (CPython) |
| Memory management | ARC (deterministic) | Garbage collector |
| Hello world binary | 49KB | ~50MB (with runtime) |
| Startup time | <1ms | ~30ms |
| Concurrency | spawn/await (real parallelism) | asyncio (GIL limits CPU parallelism) |
| Package manager | wyn pkg | pip |
Performance Benchmarks
All benchmarks on Apple M4, macOS 15. Wyn compiled with clang -O2, Python 3.12.
| Benchmark | Wyn | Python 3.12 | Speedup |
|---|---|---|---|
| fib(35) recursive | 33ms | ~2,800ms | 85x |
| Sort 10K ints | 1ms | ~3ms | 3x |
| 1M string appends | 6ms | ~200ms | 33x |
| 100K method chains | 8ms | ~50ms | 6x |
| HTTP server (req/s) | ~12,000 | ~1,200 | 10x |
The fib(35) benchmark is pure recursive computation — no stdlib tricks. Wyn compiles to C, so CPU-bound code runs at near-native speed. Python's interpreter adds overhead on every function call.
Syntax Comparison
Wyn's syntax is intentionally close to Python. If you can read Python, you can read Wyn.
Variables and Functions
# Python
def greet(name: str) -> str:
return f"Hello, {name}!"
names = ["Alice", "Bob", "Charlie"]
for name in names:
print(greet(name))// Wyn
fn greet(name: string) -> string {
return "Hello, ${name}!"
}
var names = ["Alice", "Bob", "Charlie"]
for name in names {
println(greet(name))
}Key differences: fn instead of def, curly braces instead of indentation, var for variable declarations, explicit types in function signatures.
Classes vs Structs
# Python
class Point:
def __init__(self, x: int, y: int):
self.x = x
self.y = y
def distance(self, other: "Point") -> float:
return ((other.x - self.x)**2 + (other.y - self.y)**2)**0.5
p = Point(3, 4)
print(p.distance(Point(0, 0)))// Wyn
struct Point {
x: int
y: int
fn distance(self, other: Point) -> float {
var dx = (other.x - self.x) * (other.x - self.x)
var dy = (other.y - self.y) * (other.y - self.y)
return Math.sqrt(dx + dy)
}
}
var p = Point{x: 3, y: 4}
println(p.distance(Point{x: 0, y: 0}).to_string())No __init__ boilerplate. Fields are declared once. Methods live inside the struct body.
Concurrency
Python's GIL prevents true CPU parallelism with threads. Wyn's spawn/await runs on real OS threads.
# Python — limited by GIL for CPU work
import asyncio
async def fetch(url):
async with aiohttp.ClientSession() as session:
async with session.get(url) as resp:
return await resp.text()
async def main():
results = await asyncio.gather(
fetch("https://api.example.com/a"),
fetch("https://api.example.com/b"),
)// Wyn — true parallelism, no GIL
fn fetch(url: string) -> string {
return Http.get(url)
}
var f1 = spawn fetch("https://api.example.com/a")
var f2 = spawn fetch("https://api.example.com/b")
var r1 = await f1
var r2 = await f2No async/await coloring. No event loop setup. spawn runs the function on a thread pool worker, await gets the result.
Pattern Matching
Both languages have pattern matching, but Wyn's is more integrated with the type system.
# Python 3.10+
match command:
case "quit":
sys.exit(0)
case "hello":
print("Hi!")
case _:
print("Unknown")// Wyn
match command {
"quit" => System.exit(0)
"hello" => println("Hi!")
_ => println("Unknown")
}Wyn also matches on enum variants and Result/Option types:
match safe_div(10, 0) {
Ok(v) => println("result: ${v}")
Err(e) => println("error: ${e}")
}When to Choose Wyn
- You need compiled performance without rewriting in C or Rust
- You want tiny deployable binaries (49KB vs shipping a Python runtime)
- You need real CPU parallelism without GIL workarounds
- You're building CLI tools that need instant startup (<1ms vs ~30ms)
- You want static types with type inference (catch bugs at compile time)
- You want one binary deployment — no virtualenv, no pip install on the server
When to Choose Python
- You need access to NumPy, pandas, scikit-learn, PyTorch — Python's ML ecosystem is unmatched
- You're doing rapid prototyping where dynamic typing speeds up iteration
- You need thousands of third-party libraries for every possible use case
- You're working in a team that already knows Python
- You need Jupyter notebooks for data exploration
Deployment Comparison
| Wyn | Python | |
|---|---|---|
| Deploy artifact | Single 49KB–100KB binary | virtualenv + requirements.txt + runtime |
| Docker image | ~5MB (scratch + binary) | ~150MB+ (python:slim + deps) |
| Startup time | <1ms | ~30ms + import time |
| Memory (hello world) | ~1MB RSS | ~10MB RSS |
Try Wyn
curl -fsSL https://wynlang.com/install.sh | sh
wyn run hello.wynSee Also
- Coming from Python — detailed migration guide with side-by-side code
- Benchmarks — full performance numbers
- Python Libraries — call Python libs from Wyn
- Wyn vs Go — comparison for Go developers
- Wyn vs Rust — comparison for Rust developers