Commit 8687bd86 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

bpo-26544: Make platform.libc_ver() less slow (GH-10868)

Coarse benchmark on Fedora 29: 1.6 sec => 0.1 sec.
Co-Authored-By: default avatarAntoine Pitrou <solipsis@pitrou.net>

(cherry-picked from commit ba7c2260)
parent c275be54
...@@ -194,7 +194,10 @@ def libc_ver(executable=sys.executable,lib='',version='', chunksize=2048): ...@@ -194,7 +194,10 @@ def libc_ver(executable=sys.executable,lib='',version='', chunksize=2048):
binary = f.read(chunksize) binary = f.read(chunksize)
pos = 0 pos = 0
while pos < len(binary): 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): if not m or m.end() == len(binary):
chunk = f.read(chunksize) chunk = f.read(chunksize)
if chunk: if chunk:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment