all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Visuwesh <visuweshm@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, 63861@debbugs.gnu.org
Subject: bug#63861: [PATCH] pp.el: New "pretty printing" code
Date: Fri, 09 Jun 2023 10:59:18 -0400	[thread overview]
Message-ID: <jwvsfb07l2m.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87cz25b9rw.fsf@gmail.com> (Visuwesh's message of "Fri, 09 Jun 2023 08:51:39 +0530")

>>> BTW, how does this compare to the newly added `pp-emacs-lisp-code`?
>> Very good question.  I had completely missed that (and its `pp-use-max-width`).
>> This points to a host of integration issues between my code and the
>> existing code.  I'll have to take a deeper look.
> From what I remember, pp simply switches to use pp-emacs-lisp-code when
> the relevant user option is set.

Yup, similar to my patch, except my patch hooks into `pp-buffer`,
i.e. a lower level which hence affects more uses.

> The poor performance of pp-emacs-lisp-code made me wish
> pp-use-max-width was only obeyed by user facing commands like
> pp-eval-expression & friends.

My tests yesterday suggest `pp-emacs-lisp-code` is simply too slow to be
used except when we know beforehand that the sexp to be printed
is small.  And I can't think of a single piece of code where that's
the case.  I suspect part of the code can be improved to bring the
computational complexity of the code closer to linear, but until
someone does that, I think `pp-use-max-width` is just unusable.
Instead we could/should provide ways for the user to interactively call
a command to reformat something using `pp-emacs-lisp-code`.  Or maybe
change the code so `pp-emacs-lisp-code` is used only when the total
printed size is below a certain threshold.

>> My new code is expected to be slower than the "normal" pretty-printer,
>> but barring performance bugs in `lisp-indent-line` (such as the one
>> fixed by the patch I just sent to Thierry) it should be approximately
>> a constant factor slower.
>> AFAICT the performance of `pp-emacs-lisp-code` can be more problematic.
> Hopefully, the constant factor is quite small.

In my tests, 10x seems to be the "worst case slowdown" of `pp-region`.
On some of the tests, it's actually faster, sometimes significantly so
(presumably due to some non-linear complexity in some parts of
`pp-buffer`).

> pp-emacs-lisp-code took a lot of time to print my modest bookmark
> alist (28 entries) and for the longest time I thought some other code
> in Emacs has gone awry.

AFAICT it suffers from a pretty bad complexity.

> I haven't tested your pretty printer but pp-emacs-lisp-code could give
> some really bizarre results for lisp data.

I haven't seen "really bizarre results" with `pp-region` yet, but
I wouldn't be surprised if that can happen: I've been playing with
various pretty-printing alternatives over the years and they all seem to
suffer from weird behaviors occasionally, except for those that insert
too many line breaks.


        Stefan






  reply	other threads:[~2023-06-09 14:59 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-02 22:50 bug#63861: [PATCH] pp.el: New "pretty printing" code Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-03  5:53 ` Eli Zaretskii
2023-06-03 18:18   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-03 18:58     ` Eli Zaretskii
2023-06-12 20:21       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-13 10:55         ` Eli Zaretskii
2023-06-16 18:26           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-17  5:39             ` Eli Zaretskii
2023-06-17 16:13               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-17 16:42                 ` Eli Zaretskii
2023-06-17 22:08                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-04  3:25     ` Visuwesh
2023-06-07 15:48       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-09  3:21         ` Visuwesh
2023-06-09 14:59           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-06-09 15:09             ` Ihor Radchenko
2023-06-09 15:26               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-09 15:59                 ` Visuwesh
2023-06-09 16:04             ` Visuwesh
2023-06-05 16:12     ` Juri Linkov
2023-06-07 15:21       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-07 18:12         ` Juri Linkov
2023-06-07 19:43           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-07 14:10 ` Thierry Volpiatto
2023-06-07 15:27   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-07 16:19     ` Thierry Volpiatto
2023-06-07 21:18       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-08 16:15   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-08 18:08     ` Thierry Volpiatto
2023-06-08 22:35       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-09  0:07         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-09  5:22         ` Thierry Volpiatto
2023-06-20 20:56         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvsfb07l2m.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=63861@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=visuweshm@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.