From 2322b3aed31dccdf0ce69554ae90c541a8c112db Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sun, 6 Aug 2017 18:08:29 +0200 Subject: [PATCH] Don't use pickle in pypy. It's really slow. (Armin Rigo told me a while ago). --- parso/grammar.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/parso/grammar.py b/parso/grammar.py index d426da5..0a72ab6 100644 --- a/parso/grammar.py +++ b/parso/grammar.py @@ -1,7 +1,7 @@ import hashlib import os -from parso._compatibility import FileNotFoundError +from parso._compatibility import FileNotFoundError, is_pypy from parso.pgen2.pgen import generate_grammar from parso.utils import splitlines, source_to_unicode, parse_version_string from parso.python.diff import DiffParser @@ -107,7 +107,9 @@ class Grammar(object): old_lines=old_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) return new_node @@ -121,7 +123,9 @@ class Grammar(object): root_node = p.parse(tokens=tokens) 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) return root_node