A drop-in replacement for the popular tqdm library, accelerated with C bindings.
Install with pip install cqdm
.
Replace usages of tqdm.tqdm
with cqdm.cqdm
. This can be done
succinctly by changing your import
statement:
# was: from tqdm import tqdm
from cqdm import cqdm as tqdm
This library has about 1/5 the overhead of standard tqdm
:
This graph was generated by running performance.py
.
There are over 40 million monthly downloads of tqdm
. Let's
assume there are 40 million instances of tqdm
running every
day, each performing 100,000 iterations. This totals 92,000
seconds or 9.58 days of overhead, per day. Using a reasonable
price for CPU time on AWS, this equates to around $10
of compute, per day globally.
Switching to cqdm
would reduce this overhead by 4/5.
That means, if everyone switched to using cqdm
,
we could save $8 in CPU time per day, globally.
Of course, this ignores the increased time for installs, compilation, etc., which is nearly an order of magnitude greater than the time saved...
To develop cqdm
locally:
- Create a fresh
venv
- Install
tqdm
withpip install tqdm
- Build the C-extension with
python setup.py build
- Install it with
python setup.py install
- Run the demo with
python demo/demo.py
To generate performance graphs:
- Install
matplotlib
withpython3 -m pip install matplotlib
- If on linux, then it might be necessary to install a gui backend for
plt.show()
to function. Do so withsudo apt-get install python3-tk
- Generate the performance graph with
python demo/performance.py