Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

10
  • "slightly faster performance" ? except in practice, servers limit their bandwidth. So, you may get about N times faster, where N is the number of files to download, by using threads. Commented Feb 12, 2018 at 13:45
  • If you're just benchmarking in a controlled environment where there is no network latency, packet loss, no bandwidth limits, etc, then sure, your sequential script must be fast. Commented Feb 12, 2018 at 13:59
  • The code I've given opens three simultaneous connections and gets data from them at the same time. You don't need threads to do that. And I would love to have no network latency to project gutenberg, but that's not where I live. Commented Feb 12, 2018 at 14:15
  • it does not. next(streams[url]) is a blocking call that waits until one chunk is fully downloaded. requests.get is also blocking, it waits until the connection is made. Commented Feb 12, 2018 at 15:03
  • next blocks, yes, but that doesn't stop the other sockets from receiving data at the same time. Commented Feb 12, 2018 at 15:09