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.21.tar.gz (426.2 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.21-cp313-cp313-win_amd64.whl (887.0 kB view details)

Uploaded CPython 3.13Windows x86-64

elaraai_east_py-1.0.21-cp313-cp313-win32.whl (777.8 kB view details)

Uploaded CPython 3.13Windows x86

elaraai_east_py-1.0.21-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.21-cp313-cp313-macosx_11_0_arm64.whl (845.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

elaraai_east_py-1.0.21-cp313-cp313-macosx_10_13_x86_64.whl (914.2 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

elaraai_east_py-1.0.21-cp312-cp312-win_amd64.whl (886.7 kB view details)

Uploaded CPython 3.12Windows x86-64

elaraai_east_py-1.0.21-cp312-cp312-win32.whl (779.7 kB view details)

Uploaded CPython 3.12Windows x86

elaraai_east_py-1.0.21-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.21-cp312-cp312-macosx_11_0_arm64.whl (849.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

elaraai_east_py-1.0.21-cp312-cp312-macosx_10_13_x86_64.whl (918.4 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

elaraai_east_py-1.0.21-cp311-cp311-win_amd64.whl (886.9 kB view details)

Uploaded CPython 3.11Windows x86-64

elaraai_east_py-1.0.21-cp311-cp311-win32.whl (780.7 kB view details)

Uploaded CPython 3.11Windows x86

elaraai_east_py-1.0.21-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.21-cp311-cp311-macosx_11_0_arm64.whl (858.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

elaraai_east_py-1.0.21-cp311-cp311-macosx_10_9_x86_64.whl (913.7 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: elaraai_east_py-1.0.21.tar.gz
  • Upload date:
  • Size: 426.2 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.21.tar.gz
Algorithm Hash digest
SHA256 147a85217c2d1deb31abbc33d2262e13da36aec1eab11ab971378acf665209f6
MD5 f38a50b01cda54614c3e29ccc4915174
BLAKE2b-256 46c2be3da3dfdaa14ab2da7044d79023c51eccacd09f1c194bbae369841d5d9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.21-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 85043a44b54c405e9c7a01e0c2738c14b0fbf9472dd6ba63651e083565d12513
MD5 fd8efe049292da19d700043f74af0c25
BLAKE2b-256 905e7ba72d3547920c350a530fbf5ad2cf281844c2870e05c0b230819bd51fc8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.21-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 304f214e1f23550ef91aa3937eaf940c2fbfc594ec7e8ff73c571281b30cf1a4
MD5 f17eada85525590b5d4e684ec58a559d
BLAKE2b-256 e909db36411faf52cfc25ffa6c7cca2f933b2ad63bc3c94e94b45690e2b49d41

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.21-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.21-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c8c873005560c2436f8ae4b350bde0f0bf1bf1a86716d4ccba510511e05635cc
MD5 ac51e07094cab926980584f736788319
BLAKE2b-256 195694d669ad82a4e2a743aaf18e8948c77eeaf4a7865a0141e109141edfd655

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.21-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5994adfcc1898a0e3faa25b8d2b8cf0d3fabfa920ace3f1718d80f13ab2603bd
MD5 2f0bd16b9d7e1b338854f73a93ca7f0d
BLAKE2b-256 cb06b294f360bc2dae94531fec6882266845b9345e08dbb40f5c82b4997f830b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.21-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 91d341271a5fd810c9c7339a330a99f893db010d663efe3447c46aeb46fc9cc6
MD5 bd53f7ba139a85878121bf119100d665
BLAKE2b-256 03d49532783c8834c014bcc103a2172f2331112624e6aae2fa8bcd8fbe428fe1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.21-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 31548be141de96b6b037afb84375bc475db91c5687a6d9b841962b8cac89fda7
MD5 609c857ec3336ea772fa261b3be1dda3
BLAKE2b-256 994ce820af63f70805403374fd9af0d480710c5f6a99224cc8b4835ac000efc5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.21-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 2f3c00ca2e18728d1caca4ba53191be9ef179c474d754eaf43841f17b9b93778
MD5 1179513f325b981d8eef7331cbb2cf93
BLAKE2b-256 5b20889f45a61a9791f76080128774f9d6ec7b341775b6e3d06be22f0b46a24f

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.21-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.21-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dd96ede0f39d5be5d1ff41badd7bb03795e7574b80b4d5089b109b338ebfc77a
MD5 7d515dec3b205200750092a84951de5a
BLAKE2b-256 4d8b24482efff7d00542820572f6a529015f5f6da40da4d5a46ffcd94e9f33a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.21-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a799937d364ca73f820c5059a8c8dc50906b4ecbb8afb8c02637748a1fcb07f8
MD5 31c745a386806de81bac6fe94c5a6531
BLAKE2b-256 485459d0c755b23bb21b3f8b935993aa2631758924c8bbcb2a88980b81439fd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.21-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b7a31d5b8b47a0c98114b35d57800d6ecc92ff49efe03fca330559f87c85355a
MD5 b193bbccc4913910b2c997c1354772c9
BLAKE2b-256 c6bb862ca0a47525916a583dee27dd48efe83ac1b092d90a7a04e7df361895c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.21-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 836a65810e8b1c39f071a47e5f1fff6c99bb198bfea3d7358cffe621fc46dd63
MD5 0565e2377b5475d4bebc9659b80bd233
BLAKE2b-256 ea5a9c052a27ed8fbaeb02d96199af53c7ca694e5a9d327584adf981e4c02584

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.21-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 7fdf52336391f8d5f075fdfca1e1e04a8bb74a8d10611a4755d673325d56818e
MD5 21ef3f6dcf372a045e6334db2b6a566d
BLAKE2b-256 fc77e0260286075e3c51a6e855ef14764326cb39bc41b739239f58a7938878ed

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.21-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.21-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c0bc749f742eeb82e2b5a3692d41415745b67d3f7dc9686e9111bd569c4e8b04
MD5 3fc0a620059fbce4768103ba3fa443a4
BLAKE2b-256 e14403726b36dd95d13130cd48139981afec44f8f17643d5fef054abf6cf23e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.21-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b33d40a883d0b97acb7adacecc07750289b6322b3316de67dd24fa2faa99f569
MD5 24d97ee5797e164b4c63688e4155034a
BLAKE2b-256 2efc958e60687c8a1230d4b2ef10d56a6481c555edb905f965a27733433ad9cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.21-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 324b5132d52811499204661ff12a4f95cd53227074d1ea4d0a40a84722633f58
MD5 29af017e054839adb13f1aaf453d55ea
BLAKE2b-256 982aa3e96bd0ae2c7e7a40e26b973c46c4604fd087468e0042bf76f3fc3c1847

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