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.13.tar.gz (423.5 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.13-cp313-cp313-win_amd64.whl (886.9 kB view details)

Uploaded CPython 3.13Windows x86-64

elaraai_east_py-1.0.13-cp313-cp313-win32.whl (777.7 kB view details)

Uploaded CPython 3.13Windows x86

elaraai_east_py-1.0.13-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.13-cp313-cp313-macosx_11_0_arm64.whl (844.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

elaraai_east_py-1.0.13-cp313-cp313-macosx_10_13_x86_64.whl (913.8 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

elaraai_east_py-1.0.13-cp312-cp312-win_amd64.whl (886.8 kB view details)

Uploaded CPython 3.12Windows x86-64

elaraai_east_py-1.0.13-cp312-cp312-win32.whl (779.8 kB view details)

Uploaded CPython 3.12Windows x86

elaraai_east_py-1.0.13-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.13-cp312-cp312-macosx_11_0_arm64.whl (848.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

elaraai_east_py-1.0.13-cp312-cp312-macosx_10_13_x86_64.whl (918.0 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

elaraai_east_py-1.0.13-cp311-cp311-win_amd64.whl (886.7 kB view details)

Uploaded CPython 3.11Windows x86-64

elaraai_east_py-1.0.13-cp311-cp311-win32.whl (780.5 kB view details)

Uploaded CPython 3.11Windows x86

elaraai_east_py-1.0.13-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.13-cp311-cp311-macosx_11_0_arm64.whl (858.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

elaraai_east_py-1.0.13-cp311-cp311-macosx_10_9_x86_64.whl (913.4 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: elaraai_east_py-1.0.13.tar.gz
  • Upload date:
  • Size: 423.5 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.13.tar.gz
Algorithm Hash digest
SHA256 7f5581861f05ebb2a887173f9c12c790baed0f28c2c85d7cb7c830007269756b
MD5 43357f757cf716aa779f6a85dda75801
BLAKE2b-256 fa8850f9d6a16305a4a8e771f17979ab43a29d8fd10fbf7880ee0b472594ca74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.13-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7f1d2220361aff8e09af8d4754c72b27aafa01ffabfa614ad451baac38a83f98
MD5 8359ec9d14e3c6e6524db8a941648861
BLAKE2b-256 c01acb2efdf0f04aa95f3a9060fcb0176bda46596fd33cb5d317f699843f6bb3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.13-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 09b2c37f5cddeeea3ece7047bea0d450614939914a66e71e478680c4e38ddfb7
MD5 bfa56eb54c53879fcd548e37129fae2e
BLAKE2b-256 64e511c4ace8778f7c25f176515b4d4ad4ab8798df41a2ea331ba33dda6cf052

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.13-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.13-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 eee199e896e97a08df480e10e7b35f67f0b4ece573ab85ceb57a2b0263cf34d9
MD5 9e3c161f93633532bd8fbe796e355452
BLAKE2b-256 96a6e8e0e60878916699a8012d5f3672a84e60cef48949cec8b65a8ae53b8abf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.13-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 df9fd2d60e88b0f922d5cac33f0bc9702b816bd3b2e621d5d6cc8af94aff07aa
MD5 29c0760e0839c748cd7bab0d044d96f7
BLAKE2b-256 3c4e41ead2d5d04df540e3a0f756828cf20df6dfcb26a91803d776e2a448474f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.13-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 065dee89e13adf34dc13ddc4222f32de7fa424582a37fcd11bbf1f23fd5d7fdb
MD5 6dc4d510da5ace240ea26f83715cfbb5
BLAKE2b-256 a41cf64534cb8bdcc7714a7bdd4e1947250eb7c087c5c93b9fcf76fc2d97ab11

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.13-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ff42a83694b5b0f2219a4ced5090abb0897652b92eb52876862240ec3ac6ff1c
MD5 2fc7b611b66ee0b027ea2a42430b46bf
BLAKE2b-256 6b5ab7fc97766ae4124d01657599ad3502b5f015f3c162178ed12f34c9867733

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.13-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 46ccff1cfa8e0a7bad1d3b4e4a0ee09da9893413aeddf2efcd445c501646d042
MD5 5a8791f0dadff7a4c3e63be1efa97c14
BLAKE2b-256 98c24e75213bb0331adf20ec745f5762e0fca045e26289d34b7b8fbe6a89af4c

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.13-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.13-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e9690943d1c2043c7447c1de28371eabfc753e04701c477c4cf6324d91723748
MD5 4daf113e72b8534dff31f5a648a19944
BLAKE2b-256 87bfeb11b6c701f443637237f8903992e259df430cc76320f79df51872a2db21

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.13-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9f19691a051c6fe2df3d6587486f73db5d1ed73443b551cb5e102e03a2727d84
MD5 8582fda37420475f967f757bcdc91f4b
BLAKE2b-256 b6df321a1b9fc38fdc5e92b4ad91acc320b7f5ac89bd7a14cbe1815777a27ea0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.13-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ac97d3f1a61b8ade6f726161cb869fb1f9a50ae20690ef7248e829a66494f29b
MD5 eec55b54138cd92eb4ea67742a0ed451
BLAKE2b-256 db79d8461b3b9aa781d52a5bd01ece5c8ef57e63114ba7f7c3201b0039292932

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.13-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d4bd64a31a63c29796588af46bd4e9ba1dd016fab05231af703e00e2fbbe6bfa
MD5 087a7c8f8377b49e1c07c036b4eedd3d
BLAKE2b-256 3de6ea833a5821e5997af96aa392a6fa707c35de518ef858699797299bc7f325

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.13-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 7e885bd4033650abeedd7b1809bf72b2688265fe39818ab6341d01ac1d47b045
MD5 f009486cd79375350e2be4137e04caf7
BLAKE2b-256 f4ede71bccf03aecae854903d0f03e36a6181f077b2f4ffbd9153b4db7e504dc

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.13-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.13-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 331aedf11f8719dfd615ca768b201ff9da1d1550d25b08bc921df550948ccd93
MD5 42cc375e803c065df57927cd0401d078
BLAKE2b-256 9b5b156faf05a553e81b18c6222420f3982700cef283a34077591afddb7c8c24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.13-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ca45047459364fd3742beaece1b333dbace1ee8a4296485594e7c45c505e4b70
MD5 44cb4f840bf4f6f34963f71c1f004a76
BLAKE2b-256 ef94a037938c44c50e3a5fece865dcfc1d4fdefa0a70a46a1540ffc7b71c708f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.13-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b02d8e5041af20afc6659dc89e0b2be8b91fcd2ca17c690d444dead24122bed6
MD5 27466c25c090d25c820e6a9262c8da4d
BLAKE2b-256 1712783eaf84f35b493f3b65102435d45c0cf5b19c83ec48353a66faf1abbef3

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