[Python-checkins] cpython (3.6): Issue #28637: No longer use re in site.py.
serhiy.storchaka
python-checkins at python.org
Tue Nov 8 13:18:36 EST 2016
https://hg.python.org/cpython/rev/a822818ec74e
changeset: 104970:a822818ec74e
branch: 3.6
parent: 104968:f7f89a4e047d
user: Serhiy Storchaka <storchaka at gmail.com>
date: Tue Nov 08 20:17:35 2016 +0200
summary:
Issue #28637: No longer use re in site.py.
This makes Python startup from a virtual environment a little faster.
files:
Lib/site.py | 13 ++++---------
1 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/Lib/site.py b/Lib/site.py
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -422,8 +422,6 @@
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 @@
]
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':
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list