Use cPickle instead of pickle

Change Parso to use cPickle instead of pickle when reading/writing the
cache, which speeds up the cache significantly.

In Python 2, cPickle is up to 1000 times faster than pickle. (In Python
3, if you "import pickle", you are actually getting cPickle.)

As is the convention, the code tries to import cPickle, and if that
fails, it falls back to pickle.

This has a big impact for users of jedi-vim, since in many cases Vim
uses Python 2.
This commit is contained in:
Mike Morearty
2017-10-22 16:53:13 -07:00
committed by Dave Halter
parent 89932c368d
commit bc8566e964
2 changed files with 9 additions and 2 deletions

View File

@@ -4,11 +4,15 @@ import sys
import hashlib
import gc
import shutil
import pickle
import platform
import errno
import logging
try:
import cPickle as pickle
except:
import pickle
from parso._compatibility import FileNotFoundError
LOG = logging.getLogger(__name__)

View File

@@ -16,7 +16,10 @@ fallback token code OP, but the parser needs the actual token code.
"""
import pickle
try:
import cPickle as pickle
except:
import pickle
class Grammar(object):