examples/wrapping_generators

This commit is contained in:
Casper da Costa-Luis 2020-01-24 21:58:05 +00:00
parent 32cde4d16a
commit 6e38fc5e74
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
1 changed files with 14 additions and 0 deletions

View File

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