Skip to content

Commit ad584cb

Browse files
committed
Store compiled regex
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent eb499b8 commit ad584cb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

bpython/autocomplete.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,16 @@ def safe_eval(expr, namespace):
297297
raise EvaluationError
298298

299299

300+
attr_matches_re = re.compile(r"(\w+(\.\w+)*)\.(\w*)")
301+
300302
def attr_matches(text, namespace, autocomplete_mode):
301303
"""Taken from rlcompleter.py and bent to my will.
302304
"""
303305

304306
# Gna, Py 2.6's rlcompleter searches for __call__ inside the
305307
# instance instead of the type, so we monkeypatch to prevent
306308
# side-effects (__getattr__/__getattribute__)
307-
m = re.match(r"(\w+(\.\w+)*)\.(\w*)", text)
309+
m = attr_matches_re.match(text)
308310
if not m:
309311
return []
310312

0 commit comments

Comments
 (0)