summaryrefslogtreecommitdiffstats
path: root/examples/wrapping_generators.py
blob: 65c85bfd83021cd5bff1d2326bbfeb3bc90e23c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import numpy as np

from tqdm.contrib import tenumerate, tmap, tzip

for _ in tenumerate(range(int(1e6)), desc="builtin enumerate"):
    pass

for _ in tenumerate(np.random.random((999, 999)), desc="numpy.ndenumerate"):
    pass

for _ in tzip(np.arange(1e6), np.arange(1e6) + 1, desc="builtin zip"):
    pass

mapped = tmap(lambda x: x + 1, np.arange(1e6), desc="builtin map")
assert (np.arange(1e6) + 1 == list(mapped)).all()