mirror of
https://github.com/davidhalter/parso.git
synced 2026-02-28 20:42:48 +08:00
Don't use pickle in pypy. It's really slow. (Armin Rigo told me a while ago).
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from parso._compatibility import FileNotFoundError
|
from parso._compatibility import FileNotFoundError, is_pypy
|
||||||
from parso.pgen2.pgen import generate_grammar
|
from parso.pgen2.pgen import generate_grammar
|
||||||
from parso.utils import splitlines, source_to_unicode, parse_version_string
|
from parso.utils import splitlines, source_to_unicode, parse_version_string
|
||||||
from parso.python.diff import DiffParser
|
from parso.python.diff import DiffParser
|
||||||
@@ -107,7 +107,9 @@ class Grammar(object):
|
|||||||
old_lines=old_lines,
|
old_lines=old_lines,
|
||||||
new_lines=lines
|
new_lines=lines
|
||||||
)
|
)
|
||||||
save_module(self._hashed, path, new_node, lines, pickling=cache,
|
save_module(self._hashed, path, new_node, lines,
|
||||||
|
# Never pickle in pypy, it's slow as hell.
|
||||||
|
pickling=cache and not is_pypy,
|
||||||
cache_path=cache_path)
|
cache_path=cache_path)
|
||||||
return new_node
|
return new_node
|
||||||
|
|
||||||
@@ -121,7 +123,9 @@ class Grammar(object):
|
|||||||
root_node = p.parse(tokens=tokens)
|
root_node = p.parse(tokens=tokens)
|
||||||
|
|
||||||
if cache or diff_cache:
|
if cache or diff_cache:
|
||||||
save_module(self._hashed, path, root_node, lines, pickling=cache,
|
save_module(self._hashed, path, root_node, lines,
|
||||||
|
# Never pickle in pypy, it's slow as hell.
|
||||||
|
pickling=cache and not is_pypy,
|
||||||
cache_path=cache_path)
|
cache_path=cache_path)
|
||||||
return root_node
|
return root_node
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user