which async framework?

Antoine Pitrou solipsis at pitrou.net
Tue Mar 11 14:43:45 EDT 2014


Sturla Molden <sturla.molden <at> gmail.com> writes:
> 
> Antoine Pitrou <solipsis <at> pitrou.net> wrote:
> 
> > Yes, why use a library when you can rewrite it all yourself?
> 
> This assumes something equivalent to the library will have to be written.
> But if it can be replaced with something very minimalistic it is just
> bloat. I would also like to respond that the select module and pywin32 are
> libraries.

Lower-level ones, though. Just like C malloc() is lower-level than
Python's memory management.

This is the usual assumption that high-level libraries are made of useless
cruft piled up by careless programmers. But there are actual reasons 
why these frameworks have a significant amount of code, and people who 
decide to ignore those reasons are simply bound to reimplement 
non-trivial parts of those frameworks in less careful and less tested
ways (and they have to maintain it themselves afterwards).

What irks me with your response is that you phrased it as though writing
a good event loop was an almost trivial thing to do, which it is not
once you start considering multiple use cases and constraints. It is
quite irresponsible to suggest people don't need the power of network
programming frameworks. I would personally distrust a programmer who
chooses to reimplement their own event loop, except if they happen to
have a very brilliant track record.

> Another thing is that co-routines and "yield from" statements just
> makes it hard to follow the logic of the program. 

That's an optional part of Tornado and asyncio, though. It is very
reasonable to use Tornado or asyncio and still code in purely
callback-driven style (even though Guido himself prefers the coroutine
style).

Regards

Antoine.





More information about the Python-list mailing list