Skip to content

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

WynPython
Type systemStatic, inferredDynamic
ExecutionCompiled to C → native binaryInterpreted (CPython)
Memory managementARC (deterministic)Garbage collector
Hello world binary49KB~50MB (with runtime)
Startup time<1ms~30ms
Concurrencyspawn/await (real parallelism)asyncio (GIL limits CPU parallelism)
Package managerwyn pkgpip

Performance Benchmarks

All benchmarks on Apple M4, macOS 15. Wyn compiled with clang -O2, Python 3.12.

BenchmarkWynPython 3.12Speedup
fib(35) recursive33ms~2,800ms85x
Sort 10K ints1ms~3ms3x
1M string appends6ms~200ms33x
100K method chains8ms~50ms6x
HTTP server (req/s)~12,000~1,20010x

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
# Python
def greet(name: str) -> str:
    return f"Hello, {name}!"

names = ["Alice", "Bob", "Charlie"]
for name in names:
    print(greet(name))
wyn
// 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
# 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
// 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
# 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
// 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 f2

No 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
# Python 3.10+
match command:
    case "quit":
        sys.exit(0)
    case "hello":
        print("Hi!")
    case _:
        print("Unknown")
wyn
// Wyn
match command {
    "quit" => System.exit(0)
    "hello" => println("Hi!")
    _ => println("Unknown")
}

Wyn also matches on enum variants and Result/Option types:

wyn
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

WynPython
Deploy artifactSingle 49KB–100KB binaryvirtualenv + 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

sh
curl -fsSL https://wynlang.com/install.sh | sh
wyn run hello.wyn

See Also

MIT License — v1.11