Speedup getTerminalSize#287
Conversation
gmloose
left a comment
There was a problem hiding this comment.
Nice improvement, but I have a question about the fallback value you're using (see above).
| # We set it to (80, 25) to maintain the identical default values as the old code. | ||
| size = get_terminal_size(fallback=(80, 25)) |
There was a problem hiding this comment.
Where did you find those defaults? I don't see them in the original code. In will return (0, 0) if it cannot determine the terminal size. I can live with (80, 25), but also with (80, 24), which is the default if you don't provide a fallback. However, I'm not 100% sure if (0, 0) is treated as special value elsewhere in the code.
There was a problem hiding this comment.
(80, 25) is the default terminal size. But I guess I shouldn't have changed that in this PR, since this PR is about speed optimization. For me both (80, 25) and (0, 0) worked, but I have restored (0, 0) in this PR.
Python 3.3+ has a build in
get_terminal_sizeinshutil, so this code is not needed.Similar as #286, it does not require extensive testing, since I havent touched computations.
For a 1.5 GB FITS:
before:
5851 0.096 0.000 16.327 0.003 /home/akurek/miniconda3/envs/pybdsf_3_14/lib/python3.14/site-packages/bdsf/functions.py:1970(getTerminalSize)after:
5851 0.006 0.000 0.070 0.000 /home/akurek/miniconda3/envs/pybdsf_3_14/lib/python3.14/site-packages/bdsf/functions.py:1971(getTerminalSize)233x faster.