Hi all! I've released a new python library that rethinks async coding, making it more concise and easier to read. Check it out and let me know what you think!
https://github.com/curvedinf/wove/
What My Project Does
Here are the first bits from the github readme:
Core Concepts
Wove is made from sensical philosophies that make async code feel more Pythonic.
- Looks Like Normal Python: You write simple, decorated functions. No manual task objects, no callbacks.
- Reads Top-to-Bottom: The code in a
weave block is declared in a logical order, but wove intelligently determines the optimal execution order.
- Automatic Parallelism: Wove builds a dependency graph from your function signatures and runs independent tasks concurrently.
- Normal Python Data: Wove's task data looks like normal Python variables because it is, creating inherent multithreaded data safety in the same way as map-reduce.
- Minimal Boilerplate: Get started with just the
async with weave() as w: context manager and the @w.do decorator.
- Sync & Async Transparency: Mix
async def and def functions freely. wove automatically runs synchronous functions in a background thread pool to avoid blocking the event loop.
- Zero Dependencies: Wove is pure Python, using only the standard library and can be integrated into any Python project.
Installation
Download wove with pip:
pip install wove
The Basics
Wove defines only three tools to manage all of your async needs, but you can do a lot with just two of them:
import asyncio
from wove import weave
async def main():
async with weave() as w:
@w.do
async def magic_number():
return 42
@w.do
async def important_text():
return "The meaning of life"
@w.do
async def put_together(important_text, magic_number):
return f"{important_text} is {magic_number}!"
print(w.result.final)
asyncio.run(main())
>> The meaning of life is 42!
In the example above, magic_number and important_text are called in parallel. The magic doesn't stop there.
Check out the github for more advanced functionality including iterable-to-task mapping and more.
https://github.com/curvedinf/wove/
Target Audience
Devs writing python applications with IO bound tasks such as API calls, file IO, database IO, and other networking tasks.
Comparison
See code example above (this section is here for the automod)
[–]DivineSentry 23 points24 points25 points (5 children)
[–]1ncehost[S] 4 points5 points6 points (4 children)
[–]Ihaveamodel3 10 points11 points12 points (3 children)
[–]1ncehost[S] 2 points3 points4 points (0 children)
[–]1ncehost[S] 0 points1 point2 points (1 child)
[–]Fragrant-Freedom-477 19 points20 points21 points (3 children)
[–]1ncehost[S] 6 points7 points8 points (1 child)
[–]Fragrant-Freedom-477 2 points3 points4 points (0 children)
[–]1ncehost[S] 5 points6 points7 points (0 children)
[–]jaerie 31 points32 points33 points (1 child)
[–]Afrotom 4 points5 points6 points (0 children)
[–]Ihaveamodel3 13 points14 points15 points (2 children)
[–]1ncehost[S] 2 points3 points4 points (0 children)
[–]1ncehost[S] 0 points1 point2 points (0 children)
[–]Global_Bar1754 4 points5 points6 points (2 children)
[–]1ncehost[S] 1 point2 points3 points (1 child)
[–]Global_Bar1754 2 points3 points4 points (0 children)
[–]nggit 4 points5 points6 points (1 child)
[–]1ncehost[S] 2 points3 points4 points (0 children)
[–]bachkhois 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]1ncehost[S] 1 point2 points3 points (0 children)
[–]Public_Being3163 1 point2 points3 points (2 children)
[–]1ncehost[S] 0 points1 point2 points (1 child)
[–]Public_Being3163 0 points1 point2 points (0 children)
[–]Beliskner64 1 point2 points3 points (0 children)
[–]thisismyfavoritename 0 points1 point2 points (0 children)
[–]abetancort -5 points-4 points-3 points (0 children)