Skip to main content

cordis_py

Cordis 的 Python 实现:面向动态系统的时空可组合性(spatiotemporal composability)元框架。

当前已实现

  • Context / Fiber:插件运行时实例、生命周期状态机、依赖驱动的自动加载/卸载。
  • Effect 追踪:ctx.effect() 支持 disposer、同步/异步 iterable,卸载时 LIFO 清理。
  • 服务与依赖注入:ctx.provide()、ctx.get()、ctx.set()、inject 声明。
  • 响应式依赖:先加载消费者再加载提供者也能自动激活;提供者卸载后消费者自动退出。
  • 事件系统:on / once / emit / parallel / serial / bail / waterfall。
  • Service 基类:继承 Service 并调用 super().__init__(ctx, name) 自动注册服务。
  • Per-realm 隔离:ctx.isolate(name, realm) 可隔离同名服务。
  • 声明式 Loader:支持 JSON/YAML/TOML 配置、增量 reconcile、disable/enable。
  • 基础 HMR:开发期针对单个 Loader Entry 的模块重载。

快速开始

import asyncio
from cordis_py import Context, Service, inject


class Greeter(Service):
    def __init__(self, ctx: Context):
        super().__init__(ctx, "greeter")

    def hello(self, name: str) -> str:
        return f"Hello, {name}!"


@inject("greeter")
def greeter_plugin(ctx: Context, config: dict):
    ctx.on("app/ready", lambda msg: print(ctx.greeter.hello(msg)))
    return None


async def main():
    root = Context()
    await root.plugin(Greeter)
    await root.plugin(greeter_plugin)

    root.emit("app/ready", "Cordis")
    await root.fiber.dispose()


asyncio.run(main())

文档

参考

  • 论文:A Programming Paradigm for Spatiotemporal Composability
  • Node.js 版:Cordis v4 / DeepSeek Harness vendor

Metadata

Release files for cordis-python 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cordis-python 0.1.0
File Size Uploaded
cordis_python-0.1.0.tar.gz 36.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cordis-python 0.1.0
File Interpreter ABI Platform
cordis_python-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 59.5 kB

Release files / cordis_python-0.1.0.tar.gz

Download URL cordis_python-0.1.0.tar.gz
Size 36.9 kB
Tags Source
SHA-256 checksum
How to use checksums
18e68ae5f6701b1419a6ed2b2a74cbd150d228ad4598c7cf4b541ec963b0c0d5
BLAKE2b-256 checksum
How to use checksums
9fd4b8f27f190101bcc69ee20f576746fcd7bcce3d8af454ed6cd0119ba79874
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / cordis_python-0.1.0-py3-none-any.whl

Download URL cordis_python-0.1.0-py3-none-any.whl
Size 22.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
264105ac3549060b4b3dc191909e23e63f74ba26d8b87ef179e95f85a491edd2
BLAKE2b-256 checksum
How to use checksums
414144ef4afdeedde7dcbf0573a60547c3679548a224eeded24774b0ab46e1b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page