From 9cac894273f2c482941e531766c2bf137f1b3c06 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sun, 6 Oct 2013 06:26:36 -0500 Subject: [PATCH] Disabling gc while loading pickles for a 20% speed boost on larger libs --- AUTHORS.txt | 2 +- jedi/cache.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 294c5913..21b31904 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -20,6 +20,6 @@ Aaron Meurer (@asmeurer) Lubos Trilety Akinori Hattori (@hattya) srusskih (@srusskih) - +Steven Silvester (@blink1073) Note: (@user) means a github user name. diff --git a/jedi/cache.py b/jedi/cache.py index 1fa6eaaa..69d5e972 100644 --- a/jedi/cache.py +++ b/jedi/cache.py @@ -23,6 +23,7 @@ import os import sys import json import hashlib +import gc try: import cPickle as pickle except ImportError: @@ -256,8 +257,12 @@ class _ModulePickling(object): return None with open(self._get_hashed_path(path), 'rb') as f: - parser_cache_item = pickle.load(f) - + try: + gc.disable() + parser_cache_item = pickle.load(f) + finally: + gc.enable() + debug.dbg('pickle loaded', path) parser_cache[path] = parser_cache_item return parser_cache_item.parser