diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-08 18:17:35 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-08 18:17:35 (GMT) |
commit | 727ba7c6f4a7bf048420982cba559c76086fb9f6 (patch) | |
tree | baf97316b46dcc5afb37722d49a46f31e1c4628b | |
parent | 4778e13148ea8aa3c64fb264e2d03dbacc399991 (diff) | |
download | cpython-727ba7c6f4a7bf048420982cba559c76086fb9f6.zip cpython-727ba7c6f4a7bf048420982cba559c76086fb9f6.tar.gz cpython-727ba7c6f4a7bf048420982cba559c76086fb9f6.tar.bz2 |
Issue #28637: No longer use re in site.py.
This makes Python startup from a virtual environment a little faster.
-rw-r--r-- | Lib/site.py | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/Lib/site.py b/Lib/site.py index 0859f28..0fc9200 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -422,8 +422,6 @@ def enablerlcompleter(): sys.__interactivehook__ = register_readline -CONFIG_LINE = r'^(?P<key>(\w|[-_])+)\s*=\s*(?P<value>.*)\s*$' - def venv(known_paths): global PREFIXES, ENABLE_USER_SITE @@ -445,19 +443,16 @@ def venv(known_paths): ] if candidate_confs: - import re - config_line = re.compile(CONFIG_LINE) virtual_conf = candidate_confs[0] system_site = "true" # Issue 25185: Use UTF-8, as that's what the venv module uses when # writing the file. with open(virtual_conf, encoding='utf-8') as f: for line in f: - line = line.strip() - m = config_line.match(line) - if m: - d = m.groupdict() - key, value = d['key'].lower(), d['value'] + if '=' in line: + key, _, value = line.partition('=') + key = key.strip().lower() + value = value.strip() if key == 'include-system-site-packages': system_site = value.lower() elif key == 'home': |