guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#30053] [PATCH 1/3] Improve appearance of tabular output.


From: Maxim Cournoyer
Subject: [bug#30053] [PATCH 1/3] Improve appearance of tabular output.
Date: Wed, 21 Jul 2021 17:43:26 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Hello,

Ludovic Courtès <ludo@gnu.org> writes:

> Hi Maxim and all,
>
> Thank you for unlocking this old patch series.  :-)
>
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>>>From d8fd6c9a1b8677cd69e50fe4f3e50c60c5fb7e35 Mon Sep 17 00:00:00 2001
>> From: Steve Sprang <scs@stevesprang.com>
>> Date: Tue, 9 Jan 2018 14:00:11 -0800
>> Subject: [PATCH] utils: Add a procedure for pretty printing tabular data.
>>
>> * guix/utils.scm (pretty-print-table): New procedure.
>>
>> Co-authored-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
>> Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
>
> [...]
>
>> +(define* (pretty-print-table rows #:key (max-column-width 20))
>> +  "Print ROWS in neat columns.  All rows should be lists of strings and each
>> +row should have the same length.  The columns are separated by a tab
>> +character, and aligned using spaces.  The maximum width of each column is
>> +bound by MAX-COLUMN-WIDTH."
>
> The version that was pushed has:
>
>   (setvbuf (current-output-port) 'block)
>
> I’m in favor of removing it because it’s “impolite” so to speak :-) to
> have such a side effect buried here.  (guix ui) enables line-buffering
> on startup anyway.

Hehe, apologies.  In my experiments, using 'block buffering seemed to
improve performance a lot.  Testing it again, the difference is
insignificant.  So I'm happy to attribute this to a measurement error on
my part (perhaps I had forgotten to recompile the modified module,
leading to the discrepancy, or perhaps another process was loading the
system).

Pushed with as commit 4f51a4ac27.

> Ludo’.
>
> PS: Commit 01d7e8c2782f61e741f8beff7888adfbdb61779d shows an
>     incompatibility with some previously-fine uses of ‘cut’, but surely
>     that was the price to pay.  (An option would be to behave
>     differently depending on whether stdout is a tty or not, but that’s
>     probably bad style…)

I pondered about that (using isatty), but considering people might pipe
the output to less to interactively view it, that doesn't seem to be a
good idea.

Thanks for the feedback!

Maxim





reply via email to

[Prev in Thread] Current Thread [Next in Thread]