Created
October 11, 2017 02:52
-
-
Save akshaykarnawat/e2e170417217620cad1de30a88432fe4 to your computer and use it in GitHub Desktop.
Multi-Processing in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing.pool import Pool | |
import requests | |
import time | |
def page(symbol): | |
requests.get(url='https://finviz.com/quote.ashx?t=' + symbol) | |
start = time.time() | |
p = Pool() | |
p.map(page, ['AAPL', 'AMZN', 'GOOG', 'MSFT', 'FB']) | |
print (time.time() - start) | |
# #takes longer | |
# start = time.time() | |
# for x in ['AAPL', 'AMZN', 'GOOG', 'MSFT', 'FB']: | |
# page(x) | |
# print (time.time() - start) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment