Why still using twisted in 2020 when asyncio is part of the standard library or you can use more advanced async libraries like Trio or Curio?
What’s wrong with twisted? It’s battle tested and works well.
I have been used heavily years ago and I hate him :)
The deferred/callback/errback mechanism is very powerful, but the code readability and code maintenance is terrible.
I find asyncio easier to mantain and I really love Trio
For a while now you can use async/await with twisted. Makes the code a lot more readable.
And the article shows that… :)
Odds are, if it’s a networking or network-related problem, and someone else has encountered it in the past, Twisted will already have the solution either in Twisted itself or in its ecosystem.
That’s pretty hard to beat.
(treq maintainer here)
Thanks for this article, @moshez! It brought to mind an enhancement I’ve been wanting to make a for a while now — accepting hyperlink.URL objects directly.
hyperlink.URL is great for constructing URLs because it knows how to appropriately escape the various parts of the URL. Contrast this with the arsenal of footguns that is urllib.parse.quote(), urllib.parse.quote_plus() and friends, which also require a bunch of knowledge of URLs (or URls?). Not that you can’t do wrong with hyperlink.URL, but it’s a better baseline.