Rene Nejsum wrote:
That's what bothers me is well. 'yield from' looks too long for a simple thing it does (1); users will be confused whether they should use 'yield' or 'yield from' (2); there is no visible difference between a plain generator and a coroutine (3).
I agree, was this ever commented ? I know it maybe late in the discussion but just because you can use yield/yield from for concurrent stuff, should you?
it looks very implicit to me (breaking the second rule)
Have the delegate/event model of C# been discussed ?
As always i recommend moving the concurrent stuff to the object level, it would be so much easier to state that a message for an object is just that: An async message sent from one object to another... :-) A simple decorator like @task would be enough:
@task # explicit run instance in own thread/coroutine class SomeTask(object): def asyc_add(self, x, y) return x + y # returns a Future() with result
task = SomeTask() n = task.async_add(2,2) # Do other stuff while waiting for answer print( "result is %d" % n ) # Future will wait/hang until result is ready
I think you'll like what I'll be sending out later tonight (US Pacific time), so hold on :) (In the meantime, feel free to read up on C#'s async/await model, which is very similar to what both Guido and I are proposing and has already been pretty well received.)