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.32.tar.gz (477.0 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.32-cp313-cp313-win_amd64.whl (987.3 kB view details)

Uploaded CPython 3.13Windows x86-64

elaraai_east_py-1.0.32-cp313-cp313-win32.whl (865.2 kB view details)

Uploaded CPython 3.13Windows x86

elaraai_east_py-1.0.32-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.2 MB view details)

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

elaraai_east_py-1.0.32-cp313-cp313-macosx_11_0_arm64.whl (940.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

elaraai_east_py-1.0.32-cp313-cp313-macosx_10_13_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

elaraai_east_py-1.0.32-cp312-cp312-win_amd64.whl (986.8 kB view details)

Uploaded CPython 3.12Windows x86-64

elaraai_east_py-1.0.32-cp312-cp312-win32.whl (867.3 kB view details)

Uploaded CPython 3.12Windows x86

elaraai_east_py-1.0.32-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.2 MB view details)

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

elaraai_east_py-1.0.32-cp312-cp312-macosx_11_0_arm64.whl (944.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

elaraai_east_py-1.0.32-cp312-cp312-macosx_10_13_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

elaraai_east_py-1.0.32-cp311-cp311-win_amd64.whl (987.5 kB view details)

Uploaded CPython 3.11Windows x86-64

elaraai_east_py-1.0.32-cp311-cp311-win32.whl (867.9 kB view details)

Uploaded CPython 3.11Windows x86

elaraai_east_py-1.0.32-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.2 MB view details)

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

elaraai_east_py-1.0.32-cp311-cp311-macosx_11_0_arm64.whl (954.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

elaraai_east_py-1.0.32-cp311-cp311-macosx_10_9_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: elaraai_east_py-1.0.32.tar.gz
  • Upload date:
  • Size: 477.0 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.32.tar.gz
Algorithm Hash digest
SHA256 6faf2578edc9d9fce1d9e6bebab2f938a639475d0e377f27c639253748a0b0e0
MD5 a4ec1fbb0c60357702ded85b2256f3cc
BLAKE2b-256 f891d506230ed5b27284acd0b376f7f5b7d85c199c6ec677e92ff348659b7670

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.32-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7cfbbccaa706f4fdad508561dc07b98fedf99e8cca92491ef6ea1a6fc14e9abe
MD5 f633c4a5b0de3bfb323df07fd607cddf
BLAKE2b-256 5d46fb5833edd9012c19c456ca8fec05a70da325f06ff0a12ac9a3b72bc1bfdc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.32-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 6ff3ada3da07a4f0943ad888ee6904c5c03b8f92b65993bbd35eb420bc96232e
MD5 c9c1aa9018777915d7cc7450e4980af9
BLAKE2b-256 8ee8a0e79c45b092d8227af80ca6486c7a486de28f63fcbacec11c367db5e136

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.32-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.32-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ffafa9368181d7b9dfcd21292a0396b53200f87332eb14da7c7f8950f114d702
MD5 c6244bd53932d12be23ff89d44fb9bef
BLAKE2b-256 cf416a0d53eeb7caf5f41a3f0f91269bc8319e091cc2ed51f5510a53f74124d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.32-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1d1be4df8dca768670bfabd109993d6894afc2da09f7a50eb7de5350939b2414
MD5 21f34629e96be2da7d0bd407033c3a87
BLAKE2b-256 4f2b6dba060279a7e8ca739640be7a601e0b8a5453248c674243bd28003cd559

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.32-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c44cacf2d7af743def4273a363a206dad59b46b4fc2b35af03201c7ad08f9918
MD5 959741437d5442dd843f068ea07052c6
BLAKE2b-256 fdd412fb886230fca9e6b937fdcf907702dc6d71753ae30c1c95dbe10538bf64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.32-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b22e637ec873e20b526e8c81bb728bf7bf3c37543375e03412ccec447e13f238
MD5 d9be05032591170e9a1af74052b81fa7
BLAKE2b-256 9ed4f4c9ae2e3abbdbc432881657fffaf0043061c691e6b84987769c5cb57cb4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.32-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 4adfa34f93caf04a6ff8dbc73e20c6db07b652fc4c4d8067a884916ce8f0204a
MD5 bef051b8a1b2869a0fd1ddd828cc8659
BLAKE2b-256 6c848db1887e3b6a86f88b37bd65026d59c3c0776b7a05150787ec8507a71630

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.32-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.32-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9ce84a3e84460eaa6d8f80341aef4dc3eadece25e4ce64befc2b0003d454a3b3
MD5 034e25426541974b57c2ab1d563a9b0c
BLAKE2b-256 ccb2ff3396a67cf2d096cb949bb2485ed9071d2ba8c7c26bf2bcb6ab167f876b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.32-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5fa16618a6d9adac48b8a22acc6fc33fe432051fd253219e1dcc5cfcc70f898a
MD5 142c140eb2edea97f21251d42b08f715
BLAKE2b-256 505593c9c572e7ffeabcf905445a460eadabc925581a11d87b13a27815efb379

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.32-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 659cc29f1a1dc0522b231699d6263104ab6d414a6b8df6a55acf48ba3b1caf98
MD5 ca678726eb99ab779b28cf7f8ae90255
BLAKE2b-256 96dbb9fce8f6123ba86816e0a51945519e5e1b6d81602c6289d640aecb17a138

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.32-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6f105dce632013a6d7cf3dae97461a389f45960d156b30918378ce13c19d5340
MD5 263579f1fabc06b03a66f69d790fbbee
BLAKE2b-256 c3cf766bd630c44319a43c07d0c7684c959c3805ae57e7726f0af5d2335c819e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.32-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 2d80786f3cb54913f799c92b1182b2b677945ceec00438e95e65d95e758f1f7e
MD5 5bece61e30d02c69a1993f776a27aa1e
BLAKE2b-256 b3ee0e75ffa815cae75ac73d1e271d181d84c59ba5b5c7c5247548edd614f84d

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.32-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.32-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bd12b32b69fcf92a9d9008059c1afb690191d9891a6a71242c2389e231dde1a8
MD5 2ea94dbb61ba79c9a45d6a4b4ad6b96f
BLAKE2b-256 b941803d370bc2a16eb09e5395e511611026ffc1b5590acd879aeaa8177f230a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.32-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 02d61868c8871409635bf809c22dc4c872d67f5c0c9b6cfc18fb06662332514d
MD5 64fd0c92735e7479d734a1e337340087
BLAKE2b-256 097bac306d05a36aa77e9daccab2e7a148cb7deb5606a75bd5ca2118fb6c1001

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.32-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2b3c079e14f1953358f3a55880b32e13166d97f75a55c0d70b47e804967ebf9e
MD5 71d98700bac156c63fbe943e8f5e726e
BLAKE2b-256 6a70a3e5d612dc95a8cf610ba8a8cf428cf248c3a95e8e667aeaa839f841b127

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