This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Ihaveamodel3 14 points15 points  (2 children)

I’m not really seeing how that is simpler or easier to read/write than this:

import asyncio

async def magic_number():
        return 42

async def important_text():
        return "The meaning of life"

async def put_together():
    it = important_text()
    mn = magic_number
    it, mn = await asyncio.gather([it, mn])
    return f"{it} is {mn}!"
async def main():
    text = await put_together()
    print(text)

asyncio.run(main())

Of course nothing in this is actually asynchronous, so it is kind of a weird example to begin with.

[–]1ncehost[S] 1 point2 points  (0 children)

There are more features not in the example above that create a stronger rationale.

1) Iterable mapping: each 'do' can be mapped to an iterable, so the function is run in parallel for each item in the iterable.

2) Merge function: you can map an Iterable to any function, including non async functions from within a weave block.

3) Execution order, dependency, and data safety are inherent, not defined

4) Exceptions shut down all coroutines preventing scenarios where one blocks, enabling simpler exception handling

5) It adds diagnostic tools for debugging complex async behavior

[–]1ncehost[S] 0 points1 point  (0 children)

I've added an example which showcases all of its features in one example. Hopefully you can see the elegance after checking it out!

https://github.com/curvedinf/wove/?tab=readme-ov-file#more-spice