davidhalter / davidhalter/jedi-vim

Slow completion for python-igraph depending on current working directory

Open
#1,118 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
5.3k
Forks
369
PR merge metrics
No merged PRs in 30d

Description

### Issue

Completions for [python-igraph](https://github.com/igraph/python-igraph) are typically very slow, but the speed depends drastically on the current working directory.

If vim is run in `~`, the code
```
from igraph import Graph
g = Graph()
g.
```
takes over 30 seconds to complete. The completion becomes faster if the current working directory is better isolated from other directories. (The examples below will hopefully help to clarify what I mean by this; unfortunately I don't know how to give a precise characterization of "isolated".)

### Steps to reproduce

After cd'ing into the following directories:

1. `~`
2. `~/Python/empty` (an empty directory, but `~/Python` contains all my Python projects and scripts)
3. `~/empty/directory/with/no/python/anywhere/in/sight`

I start vim and type the code
```
from igraph import Graph
g = Graph()
g.
```
In case 1, the completion takes over 30 seconds, in case 2 it takes about 3 seconds, and in case 3 it happens basically instantaneously.

Tab completion in ipython is instantaneous in all three cases.

Vim is run with a minimal .vimrc that uses [vim-plug](https://github.com/junegunn/vim-plug) to load only jedi-vim:
```
set nocompatible

call plug#begin()
Plug 'davidhalter/jedi-vim'
call plug#end()
```

### Output of “:verbose JediDebugInfo”

#### Jedi-vim debug information

##### jedi-vim version

- jedi-vim git version: b82da7d
- jedi git submodule status: 4e175ca82bbd680cb90f462545c10a8b1c0b5f2e pythonx/jedi (v0.19.1)
- parso git submodule status: ee5edaf22ff3941cbdfa4efd8cb3e8f69779fd56 pythonx/parso (v0.8.3)

##### Global Python

Using Python version 3 to access Jedi.
- global sys.executable: `/home/ilkka/mambaforge/envs/3.11/bin/python3`
- global sys.version: `3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]`
- global site module: `/home/ilkka/mambaforge/lib/python3.10/site.py`

##### Jedi

- path: `/home/ilkka/.vim/plugged/jedi-vim/pythonx/jedi/jedi/__init__.py`
- version: 0.19.1

##### Jedi environment:

- executable: /home/ilkka/mambaforge/envs/3.11/bin/python
- sys_path:
- `/home/ilkka/mambaforge/envs/3.11/lib/python311.zip`
- `/home/ilkka/mambaforge/envs/3.11/lib/python3.11`
- `/home/ilkka/mambaforge/envs/3.11/lib/python3.11/lib-dynload`
- `/home/ilkka/mambaforge/envs/3.11/lib/python3.11/site-packages`

##### Known environments

- (/home/ilkka/mambaforge/envs/3.11/bin/python)

- (/home/ilkka/mambaforge/envs/3.11/bin/python3.11)

- (/usr/bin/python3.10)

##### Settings

```
omnifunc=jedi#completions
Last set from ~/.vim/plugged/jedi-vim/autoload/jedi.vim line 723
completeopt=menuone,longest,popup
Last set from ~/.vim/plugged/jedi-vim/autoload/jedi.vim line 701
```

#### :version
```

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Dec 05 2023 17:58:57)
Included patches: 1-579, 1969, 580-1848, 4975, 5016, 5023, 5072, 2068, 1849-1854, 1857, 1855-1857, 1331, 1858, 1858-1859, 1873, 1860-1969, 1992, 1970-1992, 2010, 1993-2068, 2106, 2069-2106, 2108, 2107-2109, 2109-3995, 4563, 4646, 4774, 4895, 4899, 4901, 4919, 213, 1840, 1846-1847, 2110-2112, 2121
Modified by team+vim@tracker.debian.org
Compiled by team+vim@tracker.debian.org
Huge version with GTK3 GUI. Features included (+) or not (-):
+acl +dnd +listcmds +postscript +termresponse
+arabic -ebcdic +localmap +printer +textobjects
+autocmd +emacs_tags +lua +profile +textprop
+autochdir +eval +menu -python +timers
-autoservername +ex_extra +mksession +python3 +title
+balloon_eval +extra_search +modify_fname +quickfix +toolbar
+balloon_eval_term -farsi +mouse +reltime +user_commands
+browse +file_in_path +mouseshape +rightleft +vartabs
++builtin_terms +find_in_path +mouse_dec +ruby +vertsplit
+byte_offset +float +mouse_gpm +scrollbind +vim9script
+channel +folding -mouse_jsbterm +signs +viminfo
+cindent -footer +mouse_netterm +smartindent +virtualedit
+clientserver +fork() +mouse_sgr +sodium +visual
+clipboard +gettext -mouse_sysmouse +sound +visualextra
+cmdline_compl -hangul_input +mouse_urxvt +spell +vreplace
+cmdline_hist +iconv +mouse_xterm +startuptime +wildignore
+cmdline_info +insert_expand +multi_byte +statusline +wildmenu
+comments +ipv6 +multi_lang -sun_workshop +windows
+conceal +job -mzscheme +syntax +writebackup
+cryptv +jumplist +netbeans_intg +tag_binary +X11
+cscope +keymap +num64 -tag_old_static -xfontset
+cursorbind +lambda +packages -tag_any_white +xim
+cursorshape +langmap +path_extra +tcl +xpm
+dialog_con_gui +libcall +perl +termguicolors +xsmp_interact
+diff +linebreak +persistent_undo +terminal +xterm_clipboard
+digraphs +lispindent +popupwin +terminfo -xterm_save
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
defaults file: "$VIMRUNTIME/defaults.vim"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/x86_64-linux-gnu -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wdate-time -g -O2 -ffile-prefix-map=/build/vim-gVT2fw/vim-8.2.3995=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lselinux -lcanberra -lsodium -lacl -lattr -lgpm -L/usr/lib -llua5.2 -Wl,-E -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.34/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python3.10/config-3.10-x86_64-linux-gnu -lpython3.10 -lcrypt -ldl -lm -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm -lruby-3.0 -lm -L/usr/lib
```

#### :messages
```
Messages maintainer: Bram Moolenaar

```

:scriptnames

```
1: ~/jedi.vimrc
2: ~/.vim/autoload/plug.vim
3: /usr/share/vim/vim82/filetype.vim
4: /usr/share/vim/vim82/ftplugin.vim
5: /usr/share/vim/vim82/indent.vim
6: /usr/share/vim/vim82/syntax/syntax.vim
7: /usr/share/vim/vim82/syntax/synload.vim
8: /usr/share/vim/vim82/syntax/syncolor.vim
9: /usr/share/vim/vim82/colors/lists/default.vim
10: ~/.vim/plugged/jedi-vim/plugin/jedi.vim
11: /usr/share/vim/vim82/plugin/getscriptPlugin.vim
12: /usr/share/vim/vim82/plugin/gzip.vim
13: /usr/share/vim/vim82/plugin/logiPat.vim
14: /usr/share/vim/vim82/plugin/manpager.vim
15: /usr/share/vim/vim82/plugin/matchparen.vim
16: /usr/share/vim/vim82/plugin/netrwPlugin.vim
17: /usr/share/vim/vim82/plugin/rrhelper.vim
18: /usr/share/vim/vim82/plugin/spellfile.vim
19: /usr/share/vim/vim82/plugin/tarPlugin.vim
20: /usr/share/vim/vim82/plugin/tohtml.vim
21: /usr/share/vim/vim82/plugin/vimballPlugin.vim
22: /usr/share/vim/vim82/plugin/zipPlugin.vim
23: ~/.vim/plugged/jedi-vim/ftplugin/python/jedi.vim
24: ~/.vim/plugged/jedi-vim/autoload/jedi.vim
25: /usr/share/vim/vim82/ftplugin/python.vim
26: ~/.vim/plugged/jedi-vim/after/ftplugin/python/jedi.vim
27: /usr/share/vim/vim82/indent/python.vim
28: ~/.vim/syntax/python.vim
29: /usr/share/vim/vim82/syntax/python.vim
30: ~/.vim/plugged/jedi-vim/after/syntax/python.vim
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the python-igraph completion in the three working-directory cases, using the `omnifunc=jedi#completions` entry point. Then read `autoload/jedi.vim`, `ftplugin/python/jedi.vim`, and the reported Jedi environment details to trace the directory-dependent delay. Done means completion is responsive and no longer varies drastically with the current working directory.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, vim
Domain
devtools, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.