Skip to main content

Cypy

A Python-like language that compiles to Cython.

Features

  • Python Compatibility: Partial Python syntax compatibility
  • Gradual Typing: Annotated variables use static types, unannotated fall back to object
  • Compile-time Checking: cypyc transpiler catches type errors early
  • Cython Backend: Compiles to Cython for high-performance C code
  • Modern Syntax: Pattern matching, enum, struct, trait, let/var, and more
  • Concurrency: go keyword for coroutines, spawn for threads
  • Pipe Operator: |> for function chaining
  • List Comprehensions: Full support with nested loops and conditions

Quick Start

# Install dependencies
pip install -e .

# Transpile a Cypy file
cypyc input.cypy

# Transpile and compile
cypyc --compile input.cypy

# Type check only
cypyc --check input.cypy

Syntax Examples

Structs

struct Point:
    x: float
    y: float
    
    def distance(self, other: Point) -> float:
        return ((self.x - other.x) ** 2 + (self.y - other.y) ** 2) ** 0.5

Pattern Matching

match value:
    case 1:
        return "one"
    case (a, b):
        return f"tuple: {a}, {b}"
    case _:
        return "other"

Enum

enum Color:
    Red
    Green
    Blue

def process_color(c: Color) -> int:
    match c:
        case Color.Red:
            return 1
        case _:
            return 0

Let/Var Variables

let x: int = 10  # Immutable, cannot be reassigned
var y: int = 20  # Mutable, can be reassigned

Pipe Operator

let result = 5 |> double |> square  # equivalent to square(double(5))

Go (Coroutines) and Spawn (Threads)

let task = go fetch_data(url)  # asyncio.create_task
let thread = spawn heavy_computation()  # threading.Thread

List Comprehensions

let squares = [x ** 2 for x in range(10) if x % 2 == 0]

Documentation

Project-Level Compilation

# Build entire project with cross-module type inference
cypyc build <project_directory>

# Build with specific entry point
cypyc build <project_directory> --entry main

# Type check only
cypyc build <project_directory> --check-only

Examples

Explore the examples/ directory for code examples:

Testing

python scripts/run_tests.py

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cypyc-0.1.0.tar.gz (338.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cypyc-0.1.0-py3-none-any.whl (270.7 kB view details)

Uploaded Python 3

File details

Details for the file cypyc-0.1.0.tar.gz.

File metadata

  • Download URL: cypyc-0.1.0.tar.gz
  • Upload date:
  • Size: 338.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cypyc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ada558433ce5081888df703906d28514970a1a32b0ad37674d68d3226020ea35
MD5 7769d69f9360fc2ac950f18a3c5cde76
BLAKE2b-256 249ff13d59d0841aec2f5d31c2bba8992918258e93442a4084603c3b25725d38

See more details on using hashes here.

File details

Details for the file cypyc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cypyc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 270.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cypyc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06470027f60998b149cfc4961076353de003ec00d2b9a7ce72d6fd46e8616f3d
MD5 a6e78cfa7beb22b4b4e799d32efe48d0
BLAKE2b-256 8db3633d1b2a46a8bd73ebae23607bf221f41e6c25ba6bf302b1b41bc293cef9

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page