unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: kobarity <kobarity@gmail.com>
To: Tom Gillespie <tgbugs@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>,
	Stefan Monnier <monnier@iro.umontreal.ca>,
	63622@debbugs.gnu.org
Subject: bug#63622: lisp/progmodes/python.el: performance regression introduced by multiline font-lock
Date: Mon, 22 May 2023 00:44:03 +0900	[thread overview]
Message-ID: <eke7pm6thepo.wl-kobarity@gmail.com> (raw)
In-Reply-To: <eke7r0raghdl.wl-kobarity@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 732 bytes --]


I wrote:
> I agree.  It seems to me that it is not python-font-lock-extend-region
> itself that is slow, but rather font-lock's processing of the area
> extended by it.  So one workaround would be to limit the number of
> lines to be extended, as in the attached patch.  If this limit is
> exceeded, the area or the entire buffer must be font-locked manually
> later.  What do you think of this idea?

The cause of the slowdown seems to be in python-info-docstring-p.  So
another option would be to improve it.  Attached is a patch that
determines that if point is in parens except for "(", it is not a
docstring.  I can't think of a case where a docstring is in parens
except for "(".  However, usually more tests should be done.

[-- Attachment #2: 0001-Optimize-python-info-docstring-p.patch --]
[-- Type: application/octet-stream, Size: 1026 bytes --]

From 749afdc3cfe781f785c95501aa58472c78b71bf7 Mon Sep 17 00:00:00 2001
From: kobarity <kobarity@gmail.com>
Date: Mon, 22 May 2023 00:01:16 +0900
Subject: [PATCH] Optimize python-info-docstring-p

* lisp/progmodes/python.el (python-info-docstring-p): Add condition
that is not inside paren except for "(".  (Bug#63622)
---
 lisp/progmodes/python.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 6fc05b246a6..af48d852182 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -6021,6 +6021,9 @@ python-info-docstring-p
           (re (concat "[uU]?[rR]?"
                       (python-rx string-delimiter))))
       (when (and
+             (not (and syntax-ppss
+                       (when-let ((pos (nth 1 syntax-ppss)))
+                         (/= (char-after pos) ?\())))
              (not (python-info-assignment-statement-p))
              (looking-at-p re)
              ;; Allow up to two consecutive docstrings only.
-- 
2.34.1


      parent reply	other threads:[~2023-05-21 15:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-21  3:14 bug#63622: lisp/progmodes/python.el: performance regression introduced by multiline font-lock Tom Gillespie
2023-05-21  4:53 ` bug#63622: source of problem identified to be python-font-lock-extend-region Tom Gillespie
2023-05-21  6:08 ` bug#63622: lisp/progmodes/python.el: performance regression introduced by multiline font-lock Eli Zaretskii
2023-05-21  7:13   ` Tom Gillespie
2023-05-21  9:31     ` kobarity
2023-05-21 15:16       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-22 14:58         ` kobarity
2023-05-22 15:08           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-23 15:45             ` kobarity
2023-05-23 17:08               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-23 19:04               ` Tom Gillespie
2023-05-23 23:21                 ` kobarity
2023-05-24 18:53                   ` Tom Gillespie
2023-05-23 23:41               ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-24 15:05                 ` kobarity
2023-05-26 10:01                   ` Eli Zaretskii
2023-05-21 15:44       ` kobarity [this message]

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=eke7pm6thepo.wl-kobarity@gmail.com \
    --to=kobarity@gmail.com \
    --cc=63622@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=tgbugs@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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).