Skip to main content

oxython

oxython is a Rust-flavoured syntax for Cython, maintained as a series of patches on top of upstream Cython rather than as a fork.

# distances.oxy
use libc::math::sqrt

struct Point:
    f64 x
    f64 y

fn f64 norm(&Point p) noexcept:
    return sqrt(p.x * p.x + p.y * p.y)

fn distances(i32 n):
    let auto total = 0.0
    for i in 0..n:
        total += norm(Point { x = i, y = 1 })
    return total

oxython code lives in .oxy modules, .oxd declaration files and .oxi includes. fn replaces def. Plain .pyx and .pxd files, including Cython's own headers, are untouched, and .pyx modules can cimport from .oxd files. See docs/syntax.md for the full language reference.

Layout

Path Contents
upstream/ git submodule pinned to a cython/cython commit
patches/ the patch series, applied in the order of patches/series
tests/ oxython's own tests, copied into the upstream test tree to run
docs/ the syntax reference
editors/vscode/ syntax highlighting for VS Code
scripts/ apply, test and refresh helpers

Using it

git clone --recursive https://github.com/oxython/oxython
cd oxython
scripts/apply.sh            # applies patches/ on top of upstream/
pip install ./upstream      # installs the patched Cython

Working on it

The patches are developed as commits on the oxython branch inside upstream/, one commit per patch.

scripts/apply.sh                    # rebuild the branch from patches/
# edit upstream/Cython/..., then commit or amend inside upstream/
scripts/test.sh                     # run the oxython tests (C and C++)
scripts/refresh.sh                  # write the commits back to patches/

To move to a newer Cython, bump the submodule, run scripts/apply.sh, fix any patch that no longer applies with git am --3way, then run scripts/refresh.sh. CI checks the series against upstream master every night, so breakage shows up early.

CI also runs upstream's own test suite with CYTHON_FORCE_OXYTHON=1, which parses every Cython file in oxython mode. That checks that the new syntax stays a strict superset of existing Cython.

Patches

  1. .oxy, .oxd and .oxi files, the oxython lexer and a compatibility switch
  2. Builtin types: i32, u8, f64, usize, ...
  3. true/false and typed literals: 10u8, 2.5f32
  4. #[...] attributes
  5. Items: fn, let, let auto, static, const, type, struct, union, enum, pub, extern from
  6. use imports
  7. :: paths
  8. Reference and pointer types: &T, &mut T, &&T, r&T, r&mut T
  9. loop:
  10. Ranges: a..b, a..=b, seq[a..b]
  11. Struct expressions: Point { x = 1, y = 2 }
  12. fn replaces def

Roadmap

These designs from the original fork are not ported yet: if let and while let, impl blocks, mod, mut bindings, scoped enums, #[repr(packed)], function pointer type syntax, and the dereference and spread operators.

License

Apache License 2.0, the same as Cython. See LICENSE.

Metadata

Release files for oxython 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oxython 0.1.0
File Size Uploaded
oxython-0.1.0.tar.gz 3.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for oxython 0.1.0
File Interpreter ABI Platform
oxython-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.1 MB

Release files / oxython-0.1.0.tar.gz

Download URL oxython-0.1.0.tar.gz
Size 3.7 MB
Tags Source
SHA-256 checksum
How to use checksums
b7ee3a132232bb5b98e0ac59f55af3917ecd1f236ed8e8edbbb6c78cc1b29fa0
BLAKE2b-256 checksum
How to use checksums
324d56947ede49f26e2ec05e9027ccec443bb3433a8b29d0240fa54d8666c366
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / oxython-0.1.0-py3-none-any.whl

Download URL oxython-0.1.0-py3-none-any.whl
Size 1.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
ff518fe4632eece7d3deb900a22530fef477c71cdfdaf4865004e25cf35efc9d
BLAKE2b-256 checksum
How to use checksums
c810dd7cd7720d033a9911dda9be905b6715958eca20defabc8fddc89ab868f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release 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