On Mon, Dec 21, 2020 at 08:22:35AM +1100, Cameron Simpson wrote:

> Anyway, I think it should be in curses (or be loaded via curses on 
> demand), and just have a clear_screen function thus:
> 
>     def clear_screen():
>         setupterm()
>         print(ti_getstr('cl'), end='', flush=True)

[...]
> >is it so bad to use a subprocess?
> 
> Yes. It is _really slow_, depends on external reaources which might not 
> be there, and subprocess brings other burdens too.  Python comes with 
> curses and that knows directly how to do this.

Do you have benchmarks showing that shelling out to "clear" or "cls" is 
actually slower than running the full curses machinery for this?

IPython claims that the magic `%clear` command shells out to `clear`, 
are there complaints about the time it takes to clear the screen?

On my computer, shelling out to "clear" takes about one hundredth of a 
millisecond, which in interactive use is pretty much instantaneous. Do 
you have examples of tight loops where this would be a bottleneck?

Other than performance, are there any other reasons why we shouldn't 
just use `os.system('clear')` (or equivalent on Windows) and delegate to 
the shell command for this?

I guess there could be unusual platforms with no shell clear command, so 
we might need a fallback.


-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/RWTLAHJZUOBM4EBYKEIXPL6M775WAIRZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to