diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-12-03 16:49:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-03 16:49:24 +0100 |
commit | 8687bd86e6f138ef0699a1e9f3f9555765949b51 (patch) | |
tree | d2ebd65958cd15320ca87ce4abd7536e97a69601 | |
parent | c275be54411d425c90e7c679ddb5321ba458f61d (diff) | |
download | cpython-git-8687bd86e6f138ef0699a1e9f3f9555765949b51.tar.gz |
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 <solipsis@pitrou.net>
(cherry-picked from commit ba7c226095703f63c78b00e56f1db8d99ac3a54a)
-rwxr-xr-x | Lib/platform.py | 5 |
1 files changed, 4 insertions, 1 deletions
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: |