Skip to content

Commit

Permalink
examples/wrapping_generators
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Jan 24, 2020
1 parent 32cde4d commit 6e38fc5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/wrapping_generators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from tqdm.contrib import tenumerate, tzip, tmap
import numpy as np

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()

0 comments on commit 6e38fc5

Please sign in to comment.