On 09/11/2017 02:35 AM, Chris Angelico wrote: > Do a quick poll here on the list. Who sees async functions as an > alternative to Twisted? Who here has even *used* Twisted? (How many > even know what it is?)
/me raises hand, slowly, cautiously looking around. I don't think of twisted so much as an alternative to threading, but rather a way of doing event-driven programming with I/O, which does work well as an alternative to threading. This model actually fits really well with protocol implementations. For example in http, each request can be an "event" that the Twisted stack can process. When using the LDAP protocol adapter, each request type can be an event (ADD, MODIFY, DELETE, etc). As I understand it, Twisted now runs in conjunction with the new async stuff. Apparently you can use both traditional callback style Twisted programming and the new async stuff together in one program. And rather than replace Twisted, the new async core in Python can actually drive Twisted. The problem with Twisted is it's really, really hard for a beginner to mentally trace the execution of code, particularly when you're using an existing protocol adapter class as your base. Took me about two weeks to fully understand the Twisted LDAP server example. Does the new Async facility in Python make it easier to trace program flow and logic? > Personally, I think of them as an alternative to threading. Basically > they're a way to use the code style of threaded I/O (functions that > block when they need to read from a socket etc) with the light-weight > efficiency of doing everything in one thread. I have never used > Twisted. If you ever want to do I/O and run a GUI at the same time, Twisted is probably going to remain your best bet since it integrates tightly with the major GUIs' event loops. -- https://mail.python.org/mailman/listinfo/python-list