1. 6

  2. 4

    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?

    1. 3

      What’s wrong with twisted? It’s battle tested and works well.

      1. 1

        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

        1. 1

          For a while now you can use async/await with twisted. Makes the code a lot more readable.

          1. 1

            And the article shows that… :)

      2. 1

        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.

      3. 2

        (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.