Taking a Leap to Parallelize
In the previous example, we fetched the prices for many stock symbols. Whether we use a simulated time delay to generate fake data, as in the example, or make a network call to get real data from a service, fetching data for each symbol will take some non-trivial amount of time. The more symbols we deal with, the longer it will take to run the code sequentially. Even though we executed the function to fetch the price sequentially, in the previous diagram we showed these calls stacked vertically. That helps to visualize that the functions, instead of being run one after the other, may be run in parallel. That is, we don’t have to wait for the fetch of the price for one symbol to complete before we start the fetch ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access