summaryrefslogtreecommitdiff
path: root/pyparsing/util.py
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2020-02-01 16:20:36 -0600
committerptmcg <ptmcg@austin.rr.com>2020-02-01 16:20:36 -0600
commit8d9ab59a2b2767ad56c9b852c325075113718c0a (patch)
treeb7c5bbb9eab2527970fa28f4de06304eabc20f1f /pyparsing/util.py
parent2e9a47cd0377fb2f481417f6b4c9a5b1a036ddd3 (diff)
downloadpyparsing-git-8d9ab59a2b2767ad56c9b852c325075113718c0a.tar.gz
Shorten pyparsing tracebacks, to clear out internal pyparsing calls; plus some micro-optimizations when using packrat parsing
Diffstat (limited to 'pyparsing/util.py')
-rw-r--r--pyparsing/util.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/pyparsing/util.py b/pyparsing/util.py
index 468fefc..0992075 100644
--- a/pyparsing/util.py
+++ b/pyparsing/util.py
@@ -75,10 +75,11 @@ def line(loc, strg):
class _UnboundedCache:
def __init__(self):
cache = {}
+ cache_get = cache.get
self.not_in_cache = not_in_cache = object()
def get(self, key):
- return cache.get(key, not_in_cache)
+ return cache_get(key, not_in_cache)
def set(self, key, value):
cache[key] = value
@@ -99,15 +100,16 @@ class _FifoCache:
def __init__(self, size):
self.not_in_cache = not_in_cache = object()
cache = collections.OrderedDict()
+ cache_get = cache.get
def get(self, key):
- return cache.get(key, not_in_cache)
+ return cache_get(key, not_in_cache)
def set(self, key, value):
cache[key] = value
try:
while len(cache) > size:
- cache.popitem(False)
+ cache.popitem(last=False)
except KeyError:
pass