Intuitive Rust-based channel concurrency using the actor/handle pattern
Compatibility
| OS | Works | Notes |
|---|---|---|
| MacOS | ✅ | Tested works |
| Linux | ⚠️ | WIP - Might release it as a standalone package? |
| Windows | ❌ | Feel free to fork & build it yourself. I never will. |
Install
$ pip install fechan
About
The fechan package ("Fe" = Iron = Rust + "chan" = channels) was designed to be intuitive. The fact that it is written in Rust does give it a measurable performance boost, it is ~1.5x faster than Python's built-in threading + queue libraries, but at the end of the day OS threads perform (more or less) the same regardless of the laguage used to spawn them.
The real benefit to using fechan comes from its intuitive API. All of the manual queue.Queue() / threading.Thread() / thread.join() operations required with Python's built-in threading + queue libraries are replaced by a simple "send + close + collect" pattern in fechan.
That's it, that's the whole API.
Example
Consider a typical Python concurrency workflow using Python's threading + queue libraries:
import threading
import queue
def some_cpu_or_io_func(x):
"""
Some placeholder function for CPU bound / IO bound work
"""
return x * x
def thread_worker(fn, args, q):
try:
q.put(fn(*args))
except Exception as e:
q.put(str(e))
queue_results = queue.Queue()
threads = []
for i in range(100):
t = threading.Thread(target = thread_worker, args = (some_cpu_or_io_func, (i, ), queue_results))
t.start()
threads.append(t)
for t in threads:
t.join()
results = [queue_results.get() for _ in range(100)]
We can compare that to the much more concise fechan workflow:
from fechan import create_channel
def some_cpu_or_io_func(x):
"""
A placeholder function for CPU bound / IO bound work
"""
return x * x
# The entire "send + close + collect" API:
actor, handle = create_channel()
for i in range(100):
handle.send(some_cpu_or_io_func, (i, ))
handle.close()
results = actor.collect_results()
Metadata
Release files for fechan 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fechan-0.2.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl | CPython 3.12 | CPython 3.12 | macOS 10.12+ universal2 (ARM64, x86-64), macOS 11.0+ ARM64, macOS 10.12+ x86-64 | Details for fechan-0.2.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
Release files / fechan-0.2.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | fechan-0.2.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 520.3 kB |
| Tags | CPython 3.12 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
137273b0815cc78dbe623e2ca1cc4a46e1dd438640e4855b9873eb026f01e4a2
|
|
BLAKE2b-256 checksum How to use checksums |
eaa8aee2c034fe9c76179efc55b9371f1c8fa45ed96122eb856387e35503a7bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.7
|
Security for fechan 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.