From: Noam Postavsky <npostavs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Ivan Oreshnikov <oreshnikov.ivan@gmail.com>, 39598@debbugs.gnu.org
Subject: bug#39598: 26.3; Emacs is extremely unresponsive on a trivial python file
Date: Thu, 12 Mar 2020 23:00:09 -0400 [thread overview]
Message-ID: <87imj96jt2.fsf@gmail.com> (raw)
In-Reply-To: <83h7zsnum0.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 15 Feb 2020 10:05:27 +0200")
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Ivan Oreshnikov <oreshnikov.ivan@gmail.com>
>> Date: Fri, 14 Feb 2020 17:31:48 +0100
>> Cc: 39598@debbugs.gnu.org
>>
>> Ok, here's the full expansion of the relevant part of the profiler report:
>
> Looks like this part of python-nav--forward-sexp needs some
> optimizations:
Actually, it seems the main problem is a bit higher up.
python-info-docstring-p calls python-nav-backward-sexp repeatedly, until
it hits a non-string sexp. Even though it's only checking for two sexp
strings.
(let ((counter 1)
...
;; Allow up to two consecutive docstrings only.
(>=
2
(let (last-backward-sexp-point)
(while (save-excursion
(python-nav-backward-sexp)
(setq backward-sexp-point (point))
(and (= indentation (current-indentation))
...
(looking-at-p
(concat "[uU]?[rR]?"
(python-rx string-delimiter)))))
;; Previous sexp was a string, restore point.
(goto-char backward-sexp-point)
(cl-incf counter))
counter)))
So any repetitions of the while loop after the second one are useless.
The patch (generated with --ignore-all-space) below fixes it:
--- c/lisp/progmodes/python.el
+++ i/lisp/progmodes/python.el
@@ -5135,7 +5135,8 @@ python-info-docstring-p
(>=
2
(let (last-backward-sexp-point)
- (while (save-excursion
+ (while (and (<= counter 2)
+ (save-excursion
(python-nav-backward-sexp)
(setq backward-sexp-point (point))
(and (= indentation (current-indentation))
@@ -5149,7 +5150,7 @@ python-info-docstring-p
backward-sexp-point))
(looking-at-p
(concat "[uU]?[rR]?"
- (python-rx string-delimiter)))))
+ (python-rx string-delimiter))))))
;; Previous sexp was a string, restore point.
(goto-char backward-sexp-point)
(cl-incf counter))
next prev parent reply other threads:[~2020-03-13 3:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-14 10:48 bug#39598: 26.3; Emacs is extremely unresponsive on a trivial python file Ivan Oreshnikov
2020-02-14 13:35 ` Eli Zaretskii
2020-02-14 13:50 ` Eli Zaretskii
2020-02-14 16:08 ` Ivan Oreshnikov
2020-02-14 16:17 ` Eli Zaretskii
2020-02-14 16:31 ` Ivan Oreshnikov
2020-02-15 8:05 ` Eli Zaretskii
2020-02-15 18:49 ` Ivan Oreshnikov
2020-02-15 19:22 ` Eli Zaretskii
2020-02-15 19:31 ` Ivan Oreshnikov
2020-03-13 3:00 ` Noam Postavsky [this message]
2020-09-20 8:47 ` Lars Ingebrigtsen
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=87imj96jt2.fsf@gmail.com \
--to=npostavs@gmail.com \
--cc=39598@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=oreshnikov.ivan@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.