Skip to main content

A Python-native effect system for explicit error handling and structured concurrency

Project description

pyfect

Structured effects for modern Python

Python is being used to build systems far larger and more concurrent than it was originally designed for. Async is now unavoidable, yet error handling, resource management, and concurrency remain ad‑hoc and fragile. Exceptions leak everywhere. Background tasks escape. The sync/async boundary infects entire codebases.

pyfect exists to make this situation survivable.

It provides a small, opinionated core for describing effects explicitly, handling errors as values, and enforcing structured concurrency — without turning Python into something unrecognizable.


What pyfect is

  • A Python‑native effect system inspired by functional programming, not a port of another language
  • A single execution model that can compose synchronous and asynchronous work
  • Explicit errors that compose instead of exploding control flow
  • Structured concurrency by default — no silent background work
  • A runtime‑first design where safety is enforced at execution boundaries

pyfect favors clarity, discipline, and correctness over convenience magic.


What pyfect is not

  • Not a framework
  • Not a replacement for asyncio, Trio, or AnyIO
  • Not “pure FP” or academic
  • Not decorator‑driven async magic
  • Not a grab‑bag of monadic utilities

pyfect does not attempt to encode the entire program in types, eliminate exceptions everywhere, or abstract away Python’s runtime model.


Design philosophy

Safety over convenience

If an operation can fail, it should say so. If work runs concurrently, it should be scoped. If resources are acquired, their lifetime should be explicit.

pyfect intentionally avoids APIs that:

  • spawn unscoped background tasks
  • swallow errors
  • rely on implicit global state
  • hide sync/async boundaries

Effects describe, runtimes decide

Effects are descriptions of work. Execution is centralized and controlled. Side effects only happen at the boundary, where they can be supervised, cancelled, logged, or traced.

Small core, honest utilities

The core of pyfect is intentionally small. Utilities are built on top — but only when they preserve explicit failure, structured concurrency, and resource safety.


Status

pyfect is in early design and exploration. The ideas and philosophy are being shaped before the implementation is finalized.

Expect breaking changes. Expect opinions. Expect discipline.


License

MIT

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

pyfect-0.1.0.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyfect-0.1.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file pyfect-0.1.0.tar.gz.

File metadata

  • Download URL: pyfect-0.1.0.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for pyfect-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ddedefeb3d70469b3ae3808b24e149e6c8d792369d5fbe849841a843fc11d3b4
MD5 8730c7f858aa3f7048ca1866501616d9
BLAKE2b-256 e685bcad3fa6e423de7a35e25ed9abaab8be742e6a67b66a130b20a8ef6af2cb

See more details on using hashes here.

File details

Details for the file pyfect-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyfect-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for pyfect-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18fde0676f7fe74a2e36243c3d6badbbc4c2c72c91ac7bfb3f09b884afbc8c56
MD5 2e548fbcb69fa8bd56c13896ad32f6b1
BLAKE2b-256 a8e23cfaf5167ce2cbfcbf389c383b5f1d2898a73be8c32abc0d3d4420c97008

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