From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dale Newsgroups: gmane.emacs.bugs Subject: bug#15295: which-func-mode slow in long Python tuple Date: Fri, 06 Sep 2013 19:47:19 -0500 Message-ID: <522A7797.4020903@codefu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1378514905 29111 80.91.229.3 (7 Sep 2013 00:48:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 7 Sep 2013 00:48:25 +0000 (UTC) To: 15295@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 07 02:48:27 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VI6hN-0007ky-IH for geb-bug-gnu-emacs@m.gmane.org; Sat, 07 Sep 2013 02:48:25 +0200 Original-Received: from localhost ([::1]:40277 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VI6hM-0006c1-Ri for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 Sep 2013 20:48:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VI6hA-0006a8-M5 for bug-gnu-emacs@gnu.org; Fri, 06 Sep 2013 20:48:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VI6h1-0006o9-86 for bug-gnu-emacs@gnu.org; Fri, 06 Sep 2013 20:48:12 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:37047) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VI6h1-0006n2-40 for bug-gnu-emacs@gnu.org; Fri, 06 Sep 2013 20:48:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VI6h0-0006cr-Eq for bug-gnu-emacs@gnu.org; Fri, 06 Sep 2013 20:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dale Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 07 Sep 2013 00:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 15295 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.137851488025459 (code B ref -1); Sat, 07 Sep 2013 00:48:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Sep 2013 00:48:00 +0000 Original-Received: from localhost ([127.0.0.1]:45340 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VI6gx-0006cZ-Tu for submit@debbugs.gnu.org; Fri, 06 Sep 2013 20:48:00 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57867) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VI6gs-0006cH-UM for submit@debbugs.gnu.org; Fri, 06 Sep 2013 20:47:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VI6ge-0006Tg-0r for submit@debbugs.gnu.org; Fri, 06 Sep 2013 20:47:49 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:58673) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VI6gd-0006SY-TV for submit@debbugs.gnu.org; Fri, 06 Sep 2013 20:47:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VI6gW-0006Xy-FF for bug-gnu-emacs@gnu.org; Fri, 06 Sep 2013 20:47:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VI6gN-0006Js-UE for bug-gnu-emacs@gnu.org; Fri, 06 Sep 2013 20:47:32 -0400 Original-Received: from mail-ie0-f178.google.com ([209.85.223.178]:44244) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VI6gN-0006Jl-PS for bug-gnu-emacs@gnu.org; Fri, 06 Sep 2013 20:47:23 -0400 Original-Received: by mail-ie0-f178.google.com with SMTP id f4so8727728iea.9 for ; Fri, 06 Sep 2013 17:47:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:content-type:content-transfer-encoding; bh=gLh/2EB/PIaoe/zhOmZacIhwv5jbN9JGUyKdxfyQHR8=; b=kC9y8rTd7nBe+Gmn0jkKxt+WqdQVklvi8ckt1Xr4E05vm1INd3NRaRucG3vr5JPOra Cg93kNBXrcdX2HjrFXRPZS7hR1Vw20qlwD7oyMp1oLB+YDypdBa2M4gfdO9xI63DGx7+ gBH+DKExMKquWo/O8rfg+uvSw/DUVpkGg172TFPuTeKFXURlL4fEP5tJxhyZykOR0e6+ 5d01XOPQt1JZtDDoiw4E+//MryE6htjSveZtNGTNSrjLJ5f/wvi2cfJEyV066x8q9l0v uCkf+pzfmwWKVgiVH7NwaH1QYpGp+k69aDsr1nFiel+DQb0cSWvJQHgRs+3w12M06Us2 zShw== X-Gm-Message-State: ALoCoQnmvJsC3J3mvb9IjvR+ssyvv5CNllmBPUeY/00DIIjNovDGV5sfOGlAtlJ7ZPxYrTlTgDGW X-Received: by 10.43.125.4 with SMTP id gq4mr3297217icc.1.1378514841326; Fri, 06 Sep 2013 17:47:21 -0700 (PDT) Original-Received: from dale.caliginous.net (c-50-140-165-4.hsd1.in.comcast.net. [50.140.165.4]) by mx.google.com with ESMTPSA id lp9sm514399igb.9.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 06 Sep 2013 17:47:20 -0700 (PDT) User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:78082 Archived-At: I happen to have a Python source file that has a relatively long tuple at the module top level, i.e. a Python source file containing: ---------- foo = ( "item 1", "item 2", # ...and so on for ~500 lines ) ---------- I also use which-function-mode. If I go to the end of that tuple and move the cursor in to it, Emacs becomes unusably slow. It will appear to lock up and eat 100% CPU for 10-20 seconds each time I move the cursor within the end of that tuple. Emacs remains responsive at the top of the tuple. I think this is happening because python-info-current-defun is slow when dealing with long tuples. (Maybe lists, dicts, and other things too; I only tested tuples.) Here's some elisp to produce a test case and benchmark python-info-current-defun: ---------- (progn (set-buffer (generate-new-buffer "*test*")) (python-mode) (insert "foo = (\n") (dotimes (_ 500) (insert " \"bar\",\n")) (insert ")\n") (forward-line -2) (message "%S" (benchmark-run (python-info-current-defun)))) ---------- This makes a python-mode buffer named "*test*" containing only a 500-item Python tuple, as in my above example. On my hardware, the above benchmark-run yields a result such as "(7.364507 131 0.9572049999999979)", i.e. 7.3 seconds to run. Once that *test* buffer is created, feel free to turn on which-function-mode in there and see that Emacs locks up every time you move the cursor around in the end of that tuple. (which-function-mode seems to be taking about twice the time reported by benchmark-run. Perhaps it's calling python-info-current-defun twice?) I have reproduced this behavior with "emacs -Q" using an Emacs I just built from trunk, looks like revision 114162. (I get Emacs from Git, where the master branch is 0f1532f2fe2.) I have also reproduced this with python.el from the emacs-24 branch, looks like revision 111403. Thanks to everyone who develops Emacs, an indispensable tool for me! Dale