Metadata-Version: 2.4
Name: oxython
Version: 0.1.0
Summary: Cython with a Rust-flavoured syntax in .oxy files.
Home-page: https://github.com/oxython/oxython
Author: Rin Arakaki
License: Apache-2.0
Project-URL: Source Code, https://github.com/oxython/oxython
Project-URL: Bug Tracker, https://github.com/oxython/oxython/issues
Project-URL: Upstream, https://github.com/cython/cython
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Python :: Implementation :: GraalPy
Classifier: Programming Language :: C
Classifier: Programming Language :: C++
Classifier: Programming Language :: Cython
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Software Development :: Compilers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: project-url
Dynamic: requires-python
Dynamic: summary

# oxython

oxython is a Rust-flavoured syntax for [Cython](https://github.com/cython/cython),
maintained as a series of patches on top of upstream Cython rather than as a fork.

```oxython
# 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](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

```sh
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.

```sh
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](LICENSE).
