
On 06/29/2015 07:23 AM, Nick Coghlan wrote:
On 29 Jun 2015 7:33 pm, "Guido van Rossum" <guido@python.org <mailto:guido@python.org>> wrote:
Not following this in detail, but want to note that async isn't a good
model for parallelization (except I/O) because the expectation of coroutines is single threading. The event loop serializes callbacks. Changing this would break expectations and code.
Yeah, it's a bad idea - I realised after reading your post that because submission for scheduling and waiting for a result can already be separated it should be possible in Py 3.5 to write a "parallel" asynchronous iterator that eagerly consumes the awaitables produced by another asynchronous iterator, schedules them all, then produces the awaitables in order.
(That idea is probably as clear as mud without code to show what I mean...)
Only the parts concerning "schedules them all", and "produces awaitables in order". ;-) Async IO is mainly about recapturing idle cpu time while waiting for relatively slow io. But it could also be a way to organise asynchronous code. In the earlier example with circles, and each object having it's own thread... And that running into the thousands, it can be rearranged a bit if each scheduler has it's own thread. Then objects can be assigned to schedulers instead of threads. (or something like that.) Of course that's still clear as mud at this point, but maybe a different colour of mud. ;-) Cheers, Ron