Skip to main content
4 of 5
deleted 858 characters in body; edited tags; edited title
VF1
  • 213
  • 1
  • 6

Why does opening a file take so long in python mode?

Opening a small python file, with <10 buffers open, takes a long time. Here's a gist of the profile of trying to open this file (giving up with C-g after 2 minutes).

Deactivating ido-mode tells more or less the same story. See this gist for details.

Messages during the opening of the file:

CPU profiler started
Mark saved where search started [3 times]
Making python-shell-interpreter local to  *Python Internal [792caf12c778150badeeede64c068cee]* while let-bound!
Making python-shell-interpreter-args local to  *Python Internal [792caf12c778150badeeede64c068cee]* while let-bound!
Waiting for process to die...done
Quit

What's amazing is that after I quit the find-file with C-g, and re-open the same file with C-x C-f again, it loads, instantly. If, after this, I try to newly open another small python files, I have the exact same behavior - first time, emacs hangs, second time, emacs opens the file instantaneously.

None of the minor modes that are active seem threatening (I've removed all the cumbersome ones). Here are the minor modes that are activated in python mode (at least as captured when the file successfully opens the second time).

Version

GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2016-04-17 on lgw01-04, modified by Debian

Modes for buffer that's open while opening the file (same as the ones for the file that will be opened, they're all *.py):

Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption
Blink-Cursor Column-Number Electric-Indent File-Name-Shadow Font-Lock
Global-Font-Lock Line-Number Menu-Bar Mouse-Wheel Shell-Dirtrack
Tool-Bar Tooltip Transient-Mark

(Information about these minor modes follows the major mode info.)

Lisp Interaction mode defined in `lisp-mode.el':
VF1
  • 213
  • 1
  • 6