From 8687bd86e6f138ef0699a1e9f3f9555765949b51 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 3 Dec 2018 16:49:24 +0100 Subject: bpo-26544: Make platform.libc_ver() less slow (GH-10868) Coarse benchmark on Fedora 29: 1.6 sec => 0.1 sec. Co-Authored-By: Antoine Pitrou (cherry-picked from commit ba7c226095703f63c78b00e56f1db8d99ac3a54a) --- Lib/platform.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/platform.py b/Lib/platform.py index 62a5476a8f..e04d87f258 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -194,7 +194,10 @@ def libc_ver(executable=sys.executable,lib='',version='', chunksize=2048): binary = f.read(chunksize) pos = 0 while pos < len(binary): - m = _libc_search.search(binary,pos) + if 'libc' in binary or 'GLIBC' in binary: + m = _libc_search.search(binary, pos) + else: + m = None if not m or m.end() == len(binary): chunk = f.read(chunksize) if chunk: -- cgit v1.2.1