diff options
author | Changaco <changaco@changaco.oy.lc> | 2015-04-15 18:04:29 +0200 |
---|---|---|
committer | Changaco <changaco@changaco.oy.lc> | 2015-04-15 18:04:29 +0200 |
commit | 1e7d8a8344d4c92d4b0571f34c459767c5546fdd (patch) | |
tree | 0906004025b542ac55593f15f9d0cd02e783e28e /src/lxml/_elementpath.py | |
parent | f921c4368a41c9e13bd8663d8e092d66393e7a07 (diff) | |
download | python-lxml-1e7d8a8344d4c92d4b0571f34c459767c5546fdd.tar.gz |
fix selector cache in ElementPath
Diffstat (limited to 'src/lxml/_elementpath.py')
-rw-r--r-- | src/lxml/_elementpath.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lxml/_elementpath.py b/src/lxml/_elementpath.py index d1e39a48..e560de47 100644 --- a/src/lxml/_elementpath.py +++ b/src/lxml/_elementpath.py @@ -234,8 +234,9 @@ def _build_path_iterator(path, namespaces): raise ValueError("empty namespace prefix is not supported in ElementPath") if path[-1:] == "/": path += "*" # implicit all (FIXME: keep this?) + cache_key = (path, namespaces and tuple(sorted(namespaces.items())) or None) try: - return _cache[(path, namespaces and tuple(sorted(namespaces.items())) or None)] + return _cache[cache_key] except KeyError: pass if len(_cache) > 100: @@ -265,7 +266,7 @@ def _build_path_iterator(path, namespaces): token = _next() except StopIteration: break - _cache[path] = selector + _cache[cache_key] = selector return selector |