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.8.tar.gz (405.8 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.8-cp313-cp313-win_amd64.whl (876.4 kB view details)

Uploaded CPython 3.13Windows x86-64

elaraai_east_py-1.0.8-cp313-cp313-win32.whl (768.3 kB view details)

Uploaded CPython 3.13Windows x86

elaraai_east_py-1.0.8-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.8-cp313-cp313-macosx_11_0_arm64.whl (835.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

elaraai_east_py-1.0.8-cp313-cp313-macosx_10_13_x86_64.whl (903.0 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

elaraai_east_py-1.0.8-cp312-cp312-win_amd64.whl (876.8 kB view details)

Uploaded CPython 3.12Windows x86-64

elaraai_east_py-1.0.8-cp312-cp312-win32.whl (770.1 kB view details)

Uploaded CPython 3.12Windows x86

elaraai_east_py-1.0.8-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.8-cp312-cp312-macosx_11_0_arm64.whl (839.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

elaraai_east_py-1.0.8-cp312-cp312-macosx_10_13_x86_64.whl (907.2 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

elaraai_east_py-1.0.8-cp311-cp311-win_amd64.whl (877.0 kB view details)

Uploaded CPython 3.11Windows x86-64

elaraai_east_py-1.0.8-cp311-cp311-win32.whl (770.4 kB view details)

Uploaded CPython 3.11Windows x86

elaraai_east_py-1.0.8-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.8-cp311-cp311-macosx_11_0_arm64.whl (848.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

elaraai_east_py-1.0.8-cp311-cp311-macosx_10_9_x86_64.whl (903.3 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: elaraai_east_py-1.0.8.tar.gz
  • Upload date:
  • Size: 405.8 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.8.tar.gz
Algorithm Hash digest
SHA256 33ec6f0d5112a01f911f75a146f3a606897cdff2eb1ecca3b6b4bd8436dda230
MD5 3e5bcb330c6e68339249479b4dcb30f1
BLAKE2b-256 677a56e4bd7f9019e5c193280acbce2f3b544d51d6180fedb123f0f3bd99f1de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 fdcc13088f02238c5c3f2a757bece57950315e333464f1b1d510ec19f15b94f6
MD5 252528d720e6ce795d3f8460f362d137
BLAKE2b-256 71aab5689c121b249ebce591beb63729edbf7d298caa505e84d5c82123a6fe59

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.8-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 5da4934f3f063d6af1c49ccf65230adb9e975aa76858b0b0c3a4c85e7bdca1ed
MD5 740f6051faddcf678facc4c10bbed956
BLAKE2b-256 897b702f24b748b44a398d257aca7fb489959ed64ecf47294eda863c9313249d

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.8-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.8-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 08fa756172cc7bbe37c539f3cc4732ceea5be2ad4eb95bafad895ba6fd8b3fc0
MD5 d3441a08946533bd5e04dabab95c3bec
BLAKE2b-256 82c28ade110848b4d5da4682dbbe865f5e6735de180f1a55aee2a60c566e4eb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d60c742ed5504a951870a97192f5731aa8bc55a8d12098710e1b4d1d44e4b25a
MD5 5199d5ed369b28823f32f893ae621505
BLAKE2b-256 c5a47832b03c1a94feb86aeda268f62155b1cae4f370bbaaada76e0a6dfdf50c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.8-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 23afefa97250b6454b8635e9b1838726d881e21eae303ae0b54becd1c4c4ac7b
MD5 4d1184885aae0051252fd65a3dd8511b
BLAKE2b-256 5ebbf194662609d90e5cf9a4a745cad9896a35e2d10a324ac54a7f93e27897ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3b34c15798ff5e3f791f28e4504e3535cb0f666570373a149b724b312377af16
MD5 9ee1ca79e0339bbf5e5db97faab0e22c
BLAKE2b-256 2d25ba8a987cb2e9afe7a9d4c73fa084a5bdf0fbd557c82dfa97b6ddbaede326

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.8-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 5de9b47f55d3de815d76cd1d6aa39c3fc57244552389664f5528ce6184eb428b
MD5 0ec51c9143eae22a9e41a47a4f9c795a
BLAKE2b-256 ab5d4b676c36374f698778ae8c91c25fe7492128ef7aa911b1bad82393117f06

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.8-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.8-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ee2c001871ed99f4ca55c512a708203b6b6dae20d97111e0156a41cabe81baf3
MD5 c022b45a6f386c8aa8f5329e3aabe1d6
BLAKE2b-256 7145f13fc858904b862db18dabb87419e7f12398cb04e91de5b8371014f2a959

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f20634a6af772d250992a5baa5b2d1a8e3467bf3b3ef4e3692c8fc0b598ceb90
MD5 1734d0fba647539f7c6257b9a0c2f43e
BLAKE2b-256 5269496a590e93a3697e7ba76d48e71c9b01e1af7e2b15f80e22406a065c2ba1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.8-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 475435a8db0f866ae6cebc7d1796a4075f38fdded033c32b5af88b21d3a00e6f
MD5 ab6f6a534b2fdb4f818afdac4caef479
BLAKE2b-256 37283bcb8358cc0b37c44589ac48561b450f844442bdf2d713dae8f00b65fc00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dafc7da17589340c7cec41ea81825f4f7362e4f3a9a34df2b56ebf107c29f820
MD5 79023e606df2c1415aa314bebc7fe188
BLAKE2b-256 ee8a4e2465837ac3929d298a72ed01628d779752161c02bcb37c0dd7b21e355d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.8-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 1e4f9b97e865ec8cb6079bb4f0e12c84ac8658b806324b656bd54539146c460f
MD5 e5425c83679f3f2674953131b8d5deac
BLAKE2b-256 d91a949fa189c5fa5746a538e5b1a436040a9d5fb1ec20d327cb01f6ab78922d

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.8-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.8-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dafa57af7e511929dc07c7da2f6e6d745a98d4df00645eae96c1c1603d5912db
MD5 27d9663e4885521027a8d717a92e76f8
BLAKE2b-256 fdba97bef39e7881305ec3d7307b00bf190c5d37f7d94b1bbc997be67e116efd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e40235f0f895ff09526699d4c795c651c7d10de2a7be064411896d0bb107266c
MD5 4aad17c349c6d7b5bf4e2c93be057d1f
BLAKE2b-256 adab2bb42ef32d9c13a81b3d758dd69a9fe97e0b10a1303375342a1950c28029

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.8-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6c10712d1c12c83d6f60950d883f30cc0b2086821d382fb609c8022351045eab
MD5 04648d151cb986b4a08e83c0071ba0ed
BLAKE2b-256 cfb5d7334c675ae67dbf86083d9eefa584872f6bbcc9ff8cffa551d17dcb604e

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