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.2.tar.gz (290.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.2-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.2-cp313-cp313-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

elaraai_east_py-1.0.2-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.2.tar.gz.

File metadata

  • Download URL: elaraai_east_py-1.0.2.tar.gz
  • Upload date:
  • Size: 290.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.2.tar.gz
Algorithm Hash digest
SHA256 4e54c705de69e5598491899bfee56e744730d7287414df374a38a0c43d268c5c
MD5 77f7146e7fb84d8a7299451fe5a14eda
BLAKE2b-256 0aff9e10868e5b9152c49867ae2599e493eeb277a9762f58e9a2bb5227342bec

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.2-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.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7cc4858019d8478168c5a26d1e85264436170558f226b937852c1113eea69bb9
MD5 0158fcdc7acc76ee756dd5f88db47041
BLAKE2b-256 d85ec1be09bc3050c007c26f20c97e955caada89e0bace704391551b63e60dc6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6150953331a94b3ac1cca76c0fc2a8ba7301039e93fde1a478aa8dd85c4346cf
MD5 f92f55c3dcd9849a4f25bf9bbc5e288c
BLAKE2b-256 a8686cc0c7a98ccac15b9882e2be43732599cd1e9315bdf213e7e29596540020

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.2-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 cc68a9934ac4e6c959e976b6b47d2c7e046d04adedff57a496b4be57bbfab40c
MD5 6001353309cec1429221bf751e0ef3ad
BLAKE2b-256 83d189958f4c17622a4e42ae48ad027aaa751b0b2555d28bc8d69da983841eba

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.2-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.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6c2b4fef481268b5d309e20eb3221554e83ec4fac5049a83afeed18f524da2d6
MD5 ea6bdc200f1d3745939802ce34bba52a
BLAKE2b-256 b193717ed169951dc1329694bdc265ab4cef117bbbd21ff5a7f6fce0185e69b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d9dda2d3183ae15f1f2ec080d453a27b40bd7b573da9f13af3e32d24bb0e66a0
MD5 c66245361281063fd6d61e2bc3bfbe09
BLAKE2b-256 bf1f35285422fcfcb0b90bf3dd000185cf73345faeebf46d0381acc932386bc5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ea03b466a8cff4a4d2665413a0d0b1db24e876beaa31aaf00de21d02aed57d57
MD5 56a4434bbb8aeaaacc029c3a047f91d2
BLAKE2b-256 d3c338a83005039e65bb068b9bd12f5f800e1f027fd4d4487acca8cf997b2836

See more details on using hashes here.

File details

Details for the file elaraai_east_py-1.0.2-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.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f75b9f299eef81a031a7148ba348113a34ab5a4f386217eeb9fbccea28a1e999
MD5 90d8ae3f2d639994621ec4e18ceda8df
BLAKE2b-256 16396e9578924754881ae710dc5dd63a93ee7e196f609387fef07d9eb826856d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e7b86e4f8335108514fa46ac2c365c2b112b9d57735606cb8f4343658dae2bd0
MD5 8931348380120930e269fbf910882897
BLAKE2b-256 562c5545fe9a1483b817bcd2620ee4b87f11a185a8cd4c85a532644a0cb90217

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elaraai_east_py-1.0.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4182a955f2a14ce0a02226fb67d436caa56d2268f53e3993f36211022cc48b1e
MD5 0bf1dc288bf455908264b819cb1a60d2
BLAKE2b-256 11a7611349435c531666e9f2c9ca92d15c6a5ca3d9b0160601320b859ff79f29

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