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 provides:

  • Complete type system - Full representation of all East types (primitives, containers, structs, variants, functions)
  • IR compiler - Compiles East IR nodes to executable Python functions
  • 212+ builtin functions - Array, Set, Dict, String, DateTime, Blob, Integer, Float operations
  • Serialization - East text format, JSON, and BEAST (Binary East) support
  • DateTime formatting - Custom datetime parsing and printing with format strings
  • Type analysis - IR validation and type inference
  • Platform integration - Embed East functions in Python applications

Current Status

Fully Implemented:

  • Type system (all East types)
  • IR builders and compiler
  • 212 builtin functions (100% coverage)
  • Serialization (East text, JSON, BEAST)
  • DateTime formatting (parse/print)
  • Type comparison and equality
  • Container types (Array, Set, Dict)
  • Platform integration API

Test Coverage: 980 tests passing, 84% code coverage

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
import json
from east.runtime.compiler import compile_async
from east.runtime.platform import PlatformFunction
from east.serialization.json import decode_json_for
from east.types.type_system import IntegerType, IRType, NullType, StringType

# Load IR from a file (generated by East TypeScript compiler)
# In this example, the IR represents a function that:
# 1. Logs a message
# 2. Fetches HTTP status from a URL (async)
# 3. Logs the response with timing info
with open("fetch_status.ir.json") as f:
    ir_json = json.load(f)

# Decode IR from JSON to East IR nodes
decoder = decode_json_for(IRType)
ir_bytes = json.dumps(ir_json).encode("utf-8")
fetch_status_ir = decoder(ir_bytes)

# 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 IR to Python function (handles async automatically)
compiled_fn = compile_async(fetch_status_ir, platform)

# Execute the compiled function
async def main():
    await compiled_fn("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 specific test suites (using uv)
uv run pytest tests/builtins/test_builtins.py -v
uv run pytest tests/serialization/test_json.py -v
uv run pytest tests/types/test_types.py -v

# Rebuild Cython extensions after modifying .pyx files
make build-cython

Cython Acceleration

Performance-critical modules (BEAST2 deserialization, CSV parsing, struct/variant construction) have optional Cython acceleration. Extensions compile automatically during pip install / uv sync when a C compiler is available. Without one, the package falls back to pure Python with no error.

Requires gcc and python3-dev (Linux) or Xcode CLI tools (macOS).

Architecture

Module Structure

  • east/types/ - Type system implementation

    • type_system.py - Core type definitions and constructors
    • primitives.py - Null, Boolean, Integer, Float, String, Blob, DateTime
    • containers.py - Array, Set, Dict implementations
    • structural.py - Struct, Variant, Function types
  • east/builtins/ - Builtin function implementations

    • array.py - Array operations (map, filter, reduce, sort, search, etc.)
    • set_ops.py - Set operations (union, intersection, map, reduce, etc.)
    • dict_ops.py - Dict operations (map, filter, merge, etc.)
    • string.py - String operations (split, join, regex, JSON, etc.)
    • datetime_ops.py - DateTime operations (add, diff, compare, etc.)
    • comparison.py - Comparison and equality functions
  • east/serialization/ - Serialization formats

    • east_parser.py - Parse East text format
    • east_printer.py - Print East text format
    • json.py - JSON encoding/decoding
    • beast.py - Binary East format
  • east/ir/ - Intermediate representation

    • builders.py - Helper functions for building IR nodes
    • analyze.py - Type checking and validation
  • east/runtime/ - Execution engine

    • compiler.py - Compile IR to Python functions
    • platform.py - Platform integration API
  • east/datetime_format/ - DateTime formatting

    • parse.py - Parse datetime strings with format
    • print.py - Print datetime with format
    • tokenize.py - Format string tokenization

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. Tarballed for linux-x64 and linux-arm64, attached to each GitHub Release.

    • east-c: Core runtime — type system, IR interpreter, 200+ 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, IR compiler, 212+ builtins, Cython-accelerated hot paths
    • 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.


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.4.tar.gz (293.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.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.8 MB view details)

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

elaraai_east_py-1.0.4-cp313-cp313-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

elaraai_east_py-1.0.4-cp313-cp313-macosx_10_13_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

elaraai_east_py-1.0.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.8 MB view details)

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

elaraai_east_py-1.0.4-cp312-cp312-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

elaraai_east_py-1.0.4-cp312-cp312-macosx_10_13_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

elaraai_east_py-1.0.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.9 MB view details)

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

elaraai_east_py-1.0.4-cp311-cp311-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

elaraai_east_py-1.0.4-cp311-cp311-macosx_10_9_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: elaraai_east_py-1.0.4.tar.gz
  • Upload date:
  • Size: 293.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.4.tar.gz
Algorithm Hash digest
SHA256 6eac759fa006d8278f927d210c05fec94f03a30a31eed0a201962d577eb54e5f
MD5 b198b305a21b2f7a35243a62a7423eea
BLAKE2b-256 b1092eede2166efb595b4e1749f95a3b034c0866c15eed1dd35b52c175475b97

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.4-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.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5f49bd33425d4245e08d3ff66354878174a3af27e8800cf85daf439977b3c46c
MD5 8951f31095b1c3bca3c03b2587f1ed7a
BLAKE2b-256 db941d8f2df6cb0e5e9c0bc8d89855b71b399760559bfcc93d7dcbaa1e6d5aef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dab342f4911eb678e987835913c8860e0f8fd02d84b8a0edb43776ea210d110f
MD5 25252561633e7e7bc554087fe0a12e20
BLAKE2b-256 f5149551ad00ea0bbe681017f84d810da1a7bcea0b2c9fd82517a43b1702cc24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 07f8cdebee78d2ef968e2547cb1cfa049c3ecc309063a4154f1261dcbd6fe8ef
MD5 8d1f78de1ca243205417866f516b7df1
BLAKE2b-256 1377cad8343bb5567bcff4b62e94ec60466a747324412eea3a15bcb1489c8df6

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.4-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.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 60b3b895899d1b0f87abc0b9a75816e54fc463cec2072efa49f3a9ef260c0cd3
MD5 00b549f89ea4a33d107672b2d66c7ef7
BLAKE2b-256 1ff074c9fbfb1f809cd6c446548e019051b844ad79a54352d32adbeea8d3c077

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 24054b65f04450b83703b68242f9fe1ea64f11c3834b2715390d97f56ee70293
MD5 663379c6501be91b27ebf02f6d47d81e
BLAKE2b-256 e0a0abe15c38d83d44d913f7c4f459e4c5a7921014f22c7171a1aeee20c84f89

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 bd5335b4869b3dd53a797ebf18c567e4ab23649e8a20729a5703b9ad1a94e2d9
MD5 34d15376d13309eda909d2d824784d3c
BLAKE2b-256 8e9cfa93c35eb5b56b7cba3130db815d39c3832a78b8e33a4fc84a0611aae5c4

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.4-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.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 59ce3eea6338d2ae69b0858293716bbb9cba76172b26bca87fe638edcb6608fc
MD5 a20830a57be737f004841b7ede92ccce
BLAKE2b-256 5d208576251ba5975212077466e7b038efbef96d94dfbd88391cbfd830b577e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0c1e17968263ddb8d57d7e8e5744864ad586b6771b52d0945888a6fbb43e197e
MD5 4f37e853d8431882e7900781bfb8de08
BLAKE2b-256 ca4d762f8c87518410dee7a9c7662274d3015ed2bdebe1fd8d9172a89618d991

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e51105c619f08f0a69b1200d2c4c12602ce296607eed3980cdf3f3d1201e4ca0
MD5 ed89d1c049780513f31d6666f9e56cfe
BLAKE2b-256 09b84ea3a486a08d3ced228996099b360602a5344749e77e5694c5ce5c2f3dfa

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