Skip to main content

Python runtime for the East programming language

Project description

East.py

License: BSL 1.1

Python runtime for the East programming language.

Overview

East.py is a Python backend that enables East IR to be compiled and executed in Python environments. It is a Cython bridge to the native east-c runtime — IR compilation, the builtin library, execution, and serialization all run in east-c. It provides:

  • Complete type system - Full representation of all East types (primitives, containers, structs, variants, functions)
  • East values as Python data - Use East values as ordinary Python objects with eager methods that delegate to the east-c builtins, plus runtime validation/coercion at the Python↔East boundary
  • Full builtin library - Array, Set, Dict, String, DateTime, Blob, Integer, Float operations, exposed eagerly
  • Serialization - East text format, JSON, and BEAST (Binary East) support
  • DateTime formatting - Custom datetime parsing and printing with format strings
  • Platform integration - Expose Python functions to East with the @platform_function decorator

Using East values from Python

East runtime values are usable as ordinary Python data. Containers carry their East element types and expose eager methods that run immediately by delegating to the east-c builtins (no IR, no rewrite); chained collection results stay backed by east-c.

from east import (EastArray, StringType, FloatType, StructType, VectorType,
                  East, array, coerce_to)

# Construct + validate from native Python (dicts are coerced to the struct type)
LineItem = StructType([("name", StringType), ("price", FloatType)])
items = array(LineItem, [{"name": "a", "price": 1}, {"name": "b", "price": 2.0}])

# Eager methods execute now and chain
cheap = items.filter(lambda r: r["price"] < 2.0).sorted(key=lambda r: r["price"])

# Primitive builtins live on the East.<Type> namespaces (you can't add methods
# to Python's float/str/int) — they delegate to east-c too
East.Float.sqrt(2.0)
East.String.upper_case("hi")
East.less(StringType, "a", "b")

# Validate / coerce at a boundary; a mismatch raises a path-pinpointed EastTypeError
coerce_to([1, 2, 3], VectorType(FloatType))   # -> Vector<Float>

Platform functions

Expose a Python function to East with the @platform_function decorator. It infers sync/async, validates the result against the declared output (a named EastTypeError instead of silent corruption), and auto-collects the function:

from east import platform_function, platform_functions, struct, FloatType, ArrayType

@platform_function(inputs=[FloatType, ArrayType(LineItem)], output=ArrayType(LineItem))
def convert_prices(fx_rate, items):
    return items.map(lambda r: struct({"name": r["name"], "price": r["price"] * fx_rate}, LineItem))

platform = platform_functions(__name__)   # pass to compile() to register

For NumPy/torch interop, EastVector.data / EastMatrix.data are the contiguous NumPy buffers — torch.from_numpy(m.data) and EastMatrix(FloatType, tensor.numpy()) need no manual dtype juggling (the bridge canonicalizes at the east-c boundary).

Current Status

Fully implemented: the East type system, the full builtin library (exposed both through IR compilation and the eager value methods), serialization (East text, JSON, BEAST2, CSV), DateTime formatting, runtime validation/coercion, and the platform-function integration API. The compliance suite (shared across the TypeScript, C, and Python runtimes) passes in full.

Installation

# Install from source
git clone https://github.com/elaraai/east-workspace/tree/main/libs/east-py
cd east-py
pip install -e .

Quick Start

Here's a complete example showing how to load, compile, and execute East IR with platform functions:

import asyncio
from east.runtime.compiler import compile_from_json
from east.runtime.platform import PlatformFunction
from east.types.types import IntegerType, NullType, StringType

# Load IR JSON exported by the East TypeScript compiler (raw bytes).
# In this example the IR is a function that logs a message, fetches an HTTP
# status (async), and logs the response.
with open("fetch_status.ir.json", "rb") as f:
    ir_json = f.read()

# Define platform function implementations
def log_impl(message: str) -> None:
    """Sync platform function: log a message."""
    print(message)

async def fetch_status_impl(url: str) -> str:
    """Async platform function: fetch HTTP status from URL."""
    import urllib.request
    loop = asyncio.get_event_loop()
    response = await loop.run_in_executor(None, urllib.request.urlopen, url)
    return f"{response.status} ({response.msg})"

def time_ns_impl() -> int:
    """Sync platform function: get current time in nanoseconds."""
    import time
    return time.time_ns()

# Register platform functions with type signatures
platform = [
    PlatformFunction(
        name="log",
        inputs=[StringType],
        output=NullType,
        type="sync",
        fn=log_impl
    ),
    PlatformFunction(
        name="fetch_status",
        inputs=[StringType],
        output=StringType,
        type="async",
        fn=fetch_status_impl
    ),
    PlatformFunction(
        name="time_ns",
        inputs=[],
        output=IntegerType,
        type="sync",
        fn=time_ns_impl
    ),
]

# Compile the IR to a Python callable (is_async=True: a platform fn is async)
fetch_status = compile_from_json(ir_json, platform, is_async=True)

# Execute the compiled function
async def main():
    await fetch_status("https://www.google.com")
    # Output:
    # Fetching URL: https://www.google.com
    # Response status: 200 (OK) - fetched in 123.45 ms

if __name__ == "__main__":
    asyncio.run(main())

Development

# First-time setup (installs dependencies and pre-commit hooks)
make install

# Development workflow
make test          # Run test suite
make lint          # Run linter (ruff)
make format        # Format code
make typecheck     # Type check with mypy
make check         # Run all checks (lint + typecheck + test)

# Other useful commands
make repl          # Start Python REPL with east loaded
make coverage      # Generate HTML coverage report
make lint-fix      # Auto-fix linting issues
make clean         # Clean build artifacts

# Run the compliance suite directly (executes the IR corpus through the bridge)
uv run pytest tests/test_compliance.py -v

The native extensions (the east-c bridge and the Cython hot paths) are compiled at install time. After editing a .pyx/.pxd or the linked east-c sources, rebuild with make install (from the libs/east-py lib root) to recompile them.

Native build

The package compiles the native east-c runtime into a Cython extension (the _eastc bridge) at install time — this is required: IR compilation, execution, the builtin library, and the eager value methods all run through it. A few hot paths (struct/variant construction, BEAST2/CSV decoding, ordering) have additional Cython acceleration with a pure-Python fallback, but the core bridge is not optional.

Building requires a C compiler and python3-dev (Linux) or Xcode CLI tools (macOS); extensions compile automatically during pip install / uv sync / make install.

Architecture

The builtin library, IR compiler, execution, and serialization live in the native east-c runtime; this package is the Python type system plus a Cython bridge to it.

Module Structure

  • east/types/ - Type system + value representation

    • types.py - Type constructors, guards, comparison/unification
    • values.py - Value classes (EastArray/Set/Dict/Vector/Matrix/Struct/Variant/Ref/Blob), their eager methods, is_value_of/type_of
    • coercion.py - coerce_to / assert_value_of / explain_value_of / EastTypeError
    • construct.py - Ergonomic constructors (variant/some/none/match/struct/array)
    • type_of_type.py - Homoiconic type encoding (types are East values)
  • east/namespace.py - The East.<Type> scalar builtin namespaces (Float/Integer/String/DateTime/Boolean + compare/equal/less)

  • east/datetime_format.py - Format-string tokenizer for the DateTime print/parse builtins

  • east/runtime/ - Execution engine

    • compiler.py / _compiler_eastc.pyx - Bridge to east-c: compile IR, east_call, the eager call_builtin shim, and the Python-callback invoke hook
    • platform.py - PlatformFunction + the @platform_function on-ramp
    • errors.py - EastError
  • east/serialization/ - East text, JSON, BEAST2, CSV (thin wrappers over the east-c encoders/decoders)

  • east/utils/ordering.py - East total order (compare_for/equal_for/less_for/make_east_key)

  • east/_eastc_bridge.pyx, east/_eastc.pxd - The Cython ↔ east-c value/type marshalling layer

Claude Code plugin

The East ecosystem also ships a Claude Code plugin — East language skills, example search, and preemptive diagnostics for East code — installed separately from the elaraai marketplace:

# Inside Claude Code
/plugin marketplace add elaraai/east-workspace
/plugin install east@elaraai
# From a terminal
claude plugin marketplace add elaraai/east-workspace
claude plugin install east@elaraai

License

BSL 1.1 (Business Source License):

  • Non-production use (evaluation, testing, development) is free
  • Production use by or on behalf of for-profit entities requires a commercial license
  • Code becomes AGPL-3.0 four years after each release

See LICENSE.md for full details.

Commercial licensing: support@elara.ai

Ecosystem

  • East: Statically typed, expression-based language with serializable IR. Run portable logic across TypeScript, Python, C, and other runtimes.

    • @elaraai/east: Core language SDK with type system, expressions, and reference JS compiler
  • East Node: Node.js platform functions for I/O, databases, and system operations.

  • East C: C11 native runtime for executing East IR. Distributed via npm (launcher + per-platform optional dependencies) and as tarballs on each GitHub Release.

    • @elaraai/east-c-cli: npm launcher — installs the matching native binary as an optional dependency
    • east-c: Core runtime — type system, IR interpreter, builtins, serialization (Beast2, JSON, CSV, East text)
    • east-c-std: Console, FileSystem, Fetch, Crypto, Time, Path, Random
    • east-c-cli: CLI for running East IR programs natively
  • East Python: Python runtime, standard platform, I/O, and data-science platform functions. Published to PyPI.

    • east-py: Core Python runtime — type system, Cython bridge to the east-c runtime (compiler, builtins, serialization), eager value methods
    • east-py-std: Console, FileSystem, Fetch, Crypto, Time, Path, Random
    • east-py-io: SQLite, PostgreSQL, MySQL, MongoDB, Redis, S3, FTP, SFTP, XLSX, XML, compression
    • east-py-cli: CLI for running East IR programs in Python
    • east-py-datascience (PyPI) + @elaraai/east-py-datascience (npm): Optimization (MADS, Optuna, ALNS, GoogleOR), ML (XGBoost, LightGBM, NGBoost, PyTorch, Lightning, GP), Bayesian inference (PyMC), explainability (SHAP), conformal prediction (MAPIE)
  • East UI: Typed UI component definitions and React renderer, plus VS Code preview.

  • e3 — East Execution Engine: Durable execution engine for running East pipelines at scale. Git-like content-addressable storage, automatic memoization, reactive dataflow, real-time monitoring.

Links

About Elara

East is developed by Elara AI Pty Ltd, an AI-powered platform that creates economic digital twins of businesses that optimize performance. Elara combines business objectives, decisions and data to help organizations make data-driven decisions across operations, purchasing, sales and customer engagement, and project and investment planning. East powers the computational layer of Elara solutions, enabling the expression of complex business logic and data in a simple, type-safe and portable language.


Developed by Elara AI Pty Ltd.

Project details


Download files

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

Source Distribution

elaraai_east_py-1.0.29.tar.gz (425.9 kB view details)

Uploaded Source

Built Distributions

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

elaraai_east_py-1.0.29-cp313-cp313-win_amd64.whl (893.5 kB view details)

Uploaded CPython 3.13Windows x86-64

elaraai_east_py-1.0.29-cp313-cp313-win32.whl (782.9 kB view details)

Uploaded CPython 3.13Windows x86

elaraai_east_py-1.0.29-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

elaraai_east_py-1.0.29-cp313-cp313-macosx_11_0_arm64.whl (850.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

elaraai_east_py-1.0.29-cp313-cp313-macosx_10_13_x86_64.whl (920.3 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

elaraai_east_py-1.0.29-cp312-cp312-win_amd64.whl (893.5 kB view details)

Uploaded CPython 3.12Windows x86-64

elaraai_east_py-1.0.29-cp312-cp312-win32.whl (785.4 kB view details)

Uploaded CPython 3.12Windows x86

elaraai_east_py-1.0.29-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

elaraai_east_py-1.0.29-cp312-cp312-macosx_11_0_arm64.whl (854.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

elaraai_east_py-1.0.29-cp312-cp312-macosx_10_13_x86_64.whl (924.6 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

elaraai_east_py-1.0.29-cp311-cp311-win_amd64.whl (894.0 kB view details)

Uploaded CPython 3.11Windows x86-64

elaraai_east_py-1.0.29-cp311-cp311-win32.whl (786.3 kB view details)

Uploaded CPython 3.11Windows x86

elaraai_east_py-1.0.29-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

elaraai_east_py-1.0.29-cp311-cp311-macosx_11_0_arm64.whl (864.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

elaraai_east_py-1.0.29-cp311-cp311-macosx_10_9_x86_64.whl (919.7 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

Details for the file elaraai_east_py-1.0.29.tar.gz.

File metadata

  • Download URL: elaraai_east_py-1.0.29.tar.gz
  • Upload date:
  • Size: 425.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for elaraai_east_py-1.0.29.tar.gz
Algorithm Hash digest
SHA256 f5890ba7997cac4be36ad6a9406372e21cb296d8aacf7b28817fe4bbda4afd78
MD5 83d87ff6f7a77ca5a14796e9a10c473b
BLAKE2b-256 ed7dc8a4c7886d2d23dbbb2fefd5eb2b385dcf375e46c5ec73b58813824460dd

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.29-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for elaraai_east_py-1.0.29-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6001c2f9fede6242fe71030424de922422b81afb624c8b0e995c89e66b673224
MD5 1e9f8aeccdb8829e777885e0b4dcc8c0
BLAKE2b-256 d16a5098cc853edd8cbb00f79f8bff85d385f0422c9270d4fb68969a8dfe3a36

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.29-cp313-cp313-win32.whl.

File metadata

File hashes

Hashes for elaraai_east_py-1.0.29-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 03cca630988847b60775cd2b9e02a8e024307a0145886bd2be24857086cea24e
MD5 f14e2f155efa9c5792146ac8e4dac87a
BLAKE2b-256 a0c5dcbbaa1b6d9c7da5af9b1786cc84a341303b65b58767cf66afddfaa16bb0

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.29-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for elaraai_east_py-1.0.29-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 77737024702ffb236adf88f4171cfd7204b3c33c0271d6dcf5beedcc7becffe7
MD5 e5dea431afaaa5821e42ba39e9c5f993
BLAKE2b-256 c485a5b7b8b0415734d30311c12badcb1f164633c5a148df9b692233cdaef4c8

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.29-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for elaraai_east_py-1.0.29-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 21ea78736529c4220e7394115c8343ad21bf67c8cda8cb4a8ce3de467e779b9d
MD5 ff30caf73a3c33ca72818dc70072060c
BLAKE2b-256 f43eaebd9f1b8a626ea4dfe812a8d5a8382bf8b45f97a16415f8f8d281162b9f

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.29-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for elaraai_east_py-1.0.29-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 22c87593f05b26dc39e0ab2bc582c78e4a84554b47377a9d3353c54e6c7c4069
MD5 4de104370dac47cde6ddbe6d3aacb202
BLAKE2b-256 c7a1deeb64a2c3f8dcfa7d6fd0f3c81994c7a2a90aaa0a70ba991f4e8f32638d

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.29-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for elaraai_east_py-1.0.29-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 07f76dd0c8adf2543cbbbfa6bc692c3ff0f6bc7673fcc6b48e8d8faa15b221cb
MD5 a3754d69be444047ab11e492b9c2257d
BLAKE2b-256 e3939267b869e694f6ae68dae9ac5c80d29703d9c8efa624c05545e162586633

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.29-cp312-cp312-win32.whl.

File metadata

File hashes

Hashes for elaraai_east_py-1.0.29-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 e7832461d20c48a051e73a2f7a1adf0e95cff0062d90deeacca96f529be45e40
MD5 6052e32e1fd738999d544275c480f52d
BLAKE2b-256 f533d84ece514ad488f54e9c1d6e288ba95ee431076e8dd46f8cd46f78a53825

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.29-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for elaraai_east_py-1.0.29-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 83df975447ea225b9ffa5ed5c812b447f4b2a8096531aa2a44c84df5fe40026a
MD5 c03efa70732b8aa2971a17a1713c6b71
BLAKE2b-256 06c1f21054e580a129b5442271ad28fb7b3a025432cded2f16cfc7174535d35b

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.29-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for elaraai_east_py-1.0.29-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 90530211672f5847c371fc307d808ccb91f15a915822042775aea38defa77aa4
MD5 242d4dfb2116a081b202eca7d240bfe2
BLAKE2b-256 6a593b7b3d9dbe4b4c5381010e680f28b26eab99491a81614fdfa39347793c58

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.29-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for elaraai_east_py-1.0.29-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 aee674698b0a89735d358902196a8919b187164dfa50715ae31094810fca92d0
MD5 d5638f138f0bdfb4ec47958a0b5a2e58
BLAKE2b-256 99b8f2cbb856967b8e4502757608adc16e744777570f5a1985bf0172590afe09

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.29-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for elaraai_east_py-1.0.29-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ec7c442085219af60e6fb23b9aaba064ed7f492cb6969f7ca16f6deee34581e0
MD5 b537f9c32070309441c829b4ce9b8067
BLAKE2b-256 3041c7fae7416a27445e0115428bb2e02d12d6556662231af24fd35da4f88052

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.29-cp311-cp311-win32.whl.

File metadata

File hashes

Hashes for elaraai_east_py-1.0.29-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 9f9063c86a4e979d15809c4ebc7ae07a9389922655a484ba0d58c74a4e38bfe7
MD5 0b1c70bbdf22ac923fcafb7866460cc6
BLAKE2b-256 0c78cd72b6455e0a7122244cd5dbc65ff09404b3214bedd2b5242e0c5702720f

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.29-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for elaraai_east_py-1.0.29-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 eb61e285a9550b2ffeaf97964463b71089791c6bfd6288e9e63051d02d0995df
MD5 c345122d22907bbbbefe13aee27e030d
BLAKE2b-256 f642a44a63d0e39d99f8865a8e6aba433f3f96f0ea85e7d95a88bfa665d45eba

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.29-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for elaraai_east_py-1.0.29-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b4cb842975b0363f75412f902aeba7e5fe00e36e8beafc54dcd681b44685a148
MD5 71087db9dc7b0f299593d98d2a24df0e
BLAKE2b-256 723372e40cdddd53049d422a690664f78fa19dbfa69fbb697a671893f6a762b5

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.29-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for elaraai_east_py-1.0.29-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 54c6857ce27ca9ead2791a12932b27b86697edc2e7402fd1593ed14f940d916d
MD5 9f2886f2fcb84e17b071d67722ede1c2
BLAKE2b-256 14d23b97007d2569c9c874897ba219b3f9b0d4cffdcd451247ba975f871fe81a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page