mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 12:54:29 +08:00
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:
committed by
Dave Halter
parent
89932c368d
commit
bc8566e964
@@ -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__)
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user