tqdm
is a nice Python module for creating a
progressbar when processing a list of items.
It can be used in a basic for loop:
from tqdm import tqdm
= [1, 2, 3]
xs = []
ys with tqdm(total=len(xs)) as pbar:
for x in xs:
** 2)
ys.append(x pbar.update()
And with multiprocessing
as well:
import multiprocessing
from tqdm import tqdm
# The number of parallel processes to run.
= 2
PARALLELISM
def task(x):
return x ** 2
= [1, 2, 3]
xs = []
ys with tqdm(total=len(xs)) as pbar:
with multiprocessing.Pool(processes=PARALLELISM) as pool:
for y in pool.imap(task, xs):
ys.append(y) pbar.update()
[1] https://tqdm.github.io/
Feel free to comment here below. A Github account is required.