Tqdm: Make dynamic_ncols=True the default

Created on 9 Apr 2017  Â·  5Comments  Â·  Source: tqdm/tqdm

Any reason why dynamic_ncols is not True by default?

  • [X] I have visited the [source website], and in particular
    read the [known issues]
  • [X] I have searched through the [issue tracker] for duplicates
questiodocs ‽

Most helpful comment

Sorry to comment on a closed issue, but is this the right place to vote for this? I frequently run into this issue when working with long-running python scripts in tmux panes. A common use case for me is that I "zoom" into a pane when running the script and then zoom back out once I see a progress bar. Unfortunately, this doesn't work by default with tqdm. I only just found out about dynamic_ncols after a year or so of using tqdm, so my alternative for now is to ensure I add dynamic_ncols=True every time I use tqdm in any interactive script.

As far as I can tell from here, the overhead due to dynamic resizing is relatively small. However, if it cannot be added as a default, would it be possible to add an environment variable or a config that tqdm could check for to enable dynamic ncols? This would let me avoid having to add dynamic_ncols=True to every incantation of tqdm in my scripts :)

All 5 comments

could slow things down to constantly check terminal width. The ethos of tqdm is to be as fast as possible with default parameters, and to make it easy to make it even prettier at minimal cost by tweaking parameters. If there are enough votes to change a default, we'd be happy to do so.

Sorry to comment on a closed issue, but is this the right place to vote for this? I frequently run into this issue when working with long-running python scripts in tmux panes. A common use case for me is that I "zoom" into a pane when running the script and then zoom back out once I see a progress bar. Unfortunately, this doesn't work by default with tqdm. I only just found out about dynamic_ncols after a year or so of using tqdm, so my alternative for now is to ensure I add dynamic_ncols=True every time I use tqdm in any interactive script.

As far as I can tell from here, the overhead due to dynamic resizing is relatively small. However, if it cannot be added as a default, would it be possible to add an environment variable or a config that tqdm could check for to enable dynamic ncols? This would let me avoid having to add dynamic_ncols=True to every incantation of tqdm in my scripts :)

I found it really annoying that I need to check the dynamic_ncols every time, I think there should be something dedicated for tmux use case like

from tqdm import dynamic_tqdm as tqdm

that would work for any legacy code.
If it's ok may I open a PR for it?
I believe this will be more convenient than a global config and can switch between different cases easily.

Could just add this to the top of your library:

from functools import partial
from tqdm import tqdm as std_tqdm
tqdm = partial(std_tqdm, dynamic_ncols=True)

@casperdcl Awesome! Thank you.

Was this page helpful?
0 / 5 - 0 ratings