0

Using the jedi autocompletion library, I'm finding that each call to Script.completions() makes successive calls slower.

In the following code, I repeat my run function three times. It's not clear to me why, but each one takes longer than the previous.

import jedi
import time

def measure(source):
  start = time.time()
  script = jedi.Script(source, line=1, column=0)
  script.completions()
  print(' %-20s%f' % (source, time.time() - start))

def run():
  start = time.time()
  measure('min(1,2)')
  measure('max(1,2)')
  measure('print("Hello")')
  measure('abs(1)')
  measure('set()')
  measure('dict()')
  print('Total: %f' % (time.time() - start))

run()
run()
run()

Results:

 min(1,2)            0.016168
 max(1,2)            0.014470
 print("Hello")      0.016843
 abs(1)              0.019889
 set()               0.023725
 dict()              0.025874
Total: 0.117067
 min(1,2)            0.029772
 max(1,2)            0.034207
 print("Hello")      0.034982
 abs(1)              0.038538
 set()               0.041346
 dict()              0.054610
Total: 0.233565
 min(1,2)            0.047249
 max(1,2)            0.050380
 print("Hello")      0.053113
 abs(1)              0.056774
 set()               0.059072
 dict()              0.062129
Total: 0.328825

Thank you for any advice on why might this be happening and what I can do to prevent it.

tenuej
  • 129
  • 9
  • Have you tried the master branch? We have fixed some issues that look quite similar to yours. Also this should probably be part of Jedi's issue tracker. – Dave Halter Dec 14 '16 at 22:05
  • Thank you. I installed from master as you suggested and there is now no problem. I had been using jedi-0.9.0, the version currently on pypi. Presumably, whatever had been causing the slowdown has already been fixed. – tenuej Dec 14 '16 at 22:41

1 Answers1

0

This issue has been fixed in the latest master branch. Just wait until Jedi 0.10.0 will be released.

Dave Halter
  • 15,556
  • 13
  • 76
  • 103