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.3.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.3-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.3-cp313-cp313-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

elaraai_east_py-1.0.3-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.3-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.3-cp312-cp312-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

elaraai_east_py-1.0.3-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.3-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.3-cp311-cp311-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

elaraai_east_py-1.0.3-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.3.tar.gz.

File metadata

  • Download URL: elaraai_east_py-1.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 424abe199b2f4406ffc1fa4d0b3f31de7b6196400bc4800f34df3f125d884bc7
MD5 6f46bd6018b32f6660f6ddf57aa14891
BLAKE2b-256 39a0ee8519e7c90c81ee5223ee1202d7174fb4c1515ad94e658deb4b0f991d36

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.3-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.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 af14f820ebe94bf36423ecf6cb643f1286ff54e471702ebeba9e99f7e14df97f
MD5 ce7184d58ba8e5b5fdfc2f98921454df
BLAKE2b-256 f1e303f5f731f89ab184190da5bab06251b3ce886df9e8988e978736f6e844d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d68e057a966973cc3adc4143d1f53968cffeb4a4359e6e2bd492bf8eca1590cc
MD5 df0705302ae804370575755cdde173cb
BLAKE2b-256 181233337896541431e9b7d667e4bbeb98790f5f111b538ccdf12ebf6e34eb90

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.3-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0c65733c6cd4f59e981945ef70ebca9da1c32fe97cb181ac8aed427e07d80f75
MD5 a7c7ddc5049a05fef0d49a3fac3b3637
BLAKE2b-256 325f263ef06f3bb1e0c58922e9a8f9f6377f8c4a64ca7237d9e4f50e160b5214

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.3-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.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c7a7fad74d88e224224e8f104d6d4ae3157fcbf993fc7ecf7b713f427a5da3bc
MD5 6cef7f637c7675db3edb61762b4ca1f8
BLAKE2b-256 e3755fa96b219bc845d40c32c527a5ea49088e43ac2172134cd715d96fb28445

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 99e15cbf09e79f954958c29d46cf9e635357fe2440bd0b713ef3b9b21c68b817
MD5 360fce7f370b1bdc4fade54946e73e93
BLAKE2b-256 5f84d9dcb660ea032ebfde845c5f6f6576654493419dfc021f8533939a21b23b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.3-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 bc47714a0af028deb522655e1f349fbe5787f8d7a11d6d9b2029cfa230ffc3a3
MD5 4578c3fb6d737035f04829c3cdfb83a5
BLAKE2b-256 966e30dc1fa72a35d018e70e3567909d6d39ffbce44259823704076e5134a211

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.3-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.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9b7b387456bea6e6da99800cf7d4b2316b9b3af6472cafd5e3da4347aec756ff
MD5 86fc07b44e906bb825a61854596cf702
BLAKE2b-256 305d586303f41eb1d4370482c24393ee8aa97dfdbc587970b76c306a518b1300

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2d7d05e9bc333913f883d79bf66ff3135ca5658b88572a30231efeb60b4ef632
MD5 89538ecf59fbb84cc52a09c26daf1dcc
BLAKE2b-256 fb409f58a3cf807d3f3594a2e924fb6d92e592b73ef404ec57105de3fa2548d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.3-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b201d2d05fd759ed00748fdb109e1214b8eeb336f0fbf09cedc3617a18ee241e
MD5 4d783322b6b24875178c59f72fffd26f
BLAKE2b-256 062f2869a781d406a819356a625d429c361c146e997852e1e3c3187f1f8dcc15

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