gregsexton / gregsexton/ob-ipython
company-ob-ipython is unusably slow
- Dominant language
- Emacs Lisp
- Stars
- 742
- Forks
- 107
- PR merge metrics
- No merged PRs in 30d
Description
Just want to say that I love the work that's gone into this package, and I'm excited to see if there's a way to improve the usability here. Or maybe it's only me experiencing a massive slowdown? But I kind of expect not.
I'm on Mac OSX with Emacs 25.3.1.
ob-ipython version 20171209.634 installed from MELPA.
org-plus-contrib version 20171218 installed via package.el from the Org package archive.
python.el version 0.25.2 installed from MELPA Stable.
Issue: With `company-mode` enabled and `company-ob-ipython` added to my completion backends, whenever I edit an ipython source block, Emacs hangs on each character I type.
This persists even though I have `company-minimum-prefix-length` set to 3, and I'm pretty sure this is because `company-ob-ipython` shells out to a fresh jupyter client just to calculate the prefix for potential completion. I don't have actual timing data, it just seems obvious to me that's where the slowdown occurs.
I took a stab at rewriting the prefix calculation in pure Emacs lisp, but that failed for a bunch of uninteresting reasons. I'm not great at writing company backends.
One interesting thing I noticed, though, was that even when I was calculating a halfway decent prefix in Emacs lisp, completion was *still* unusably slow because the candidate list took forever to build. Again, I'm pretty sure this comes down to shelling out to a fresh jupyter client.
Sooooooo in summary, I think this is the slow code, specifically the `call-process-region` line, but I’m at a loss for how to speed it up.
(defun ob-ipython--complete-request (code &optional pos)
(let ((input (json-encode `((code . ,code)
(pos . ,(or pos (length code))))))
(args (list "--" ob-ipython-client-path "--conn-file"
(ob-ipython--get-session-from-edit-buffer (current-buffer))
"--complete")))
(with-temp-buffer
(let ((ret (apply 'call-process-region input nil
(ob-ipython--get-python) nil t nil
args)))
(if (> ret 0)
(ob-ipython--dump-error (buffer-string))
(goto-char (point-min))
(ob-ipython--collect-json))))))
Is anybody else experiencing this issue? And any ideas how to resolve it?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.