python-trio / trimeter

(not ready yet) A simple but powerful job scheduler for Trio programs
https://trimeter.readthedocs.io
Other
63 stars 3 forks source link

Which functions should we expose, and what should they be called? #3

Open njsmith opened 6 years ago

njsmith commented 6 years ago

In my initial draft, I have 3 functions:

I'm not at all sure that these three are the right set to provide, or that we have the names right.

I guess there's a two-dimensional space of calling conventions:

So in principle there are 2*5 = 10 functions we could provide here... but that's way too many and too confusing, so we need to cut it down somehow.

oremanj commented 4 years ago

Hmm.

(fun fact: for maximum inscrutability points, that run_all could also be run_all(map(partial(partial, fn), args)))

So I think the three we have now are a good three to be working with. Friendly amendment: maybe run_all can support being invoked with positional *args, so you can say run_all(thunk, thunk, thunk) instead of needing another pair of delimiters. I think the case where all the functions are listed in the code will be pretty common. Could also support both conventions, under the theory that callable iterables are rare.

Naming:

dhirschfeld commented 4 years ago

I'll put in a plug for an async as_completed function: https://github.com/groove-x/trio-util/issues/7

IIUC what run_all does but as an async iterator. I don't want to have to wait until all the functions have completed before I can pass the results off to the next step in the pipeline.