Skip to content

Commit 8687bd8

Browse files
authored
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 <[email protected]> (cherry-picked from commit ba7c226)
1 parent c275be5 commit 8687bd8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

‎Lib/platform.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ def libc_ver(executable=sys.executable,lib='',version='', chunksize=2048):
194194
binary = f.read(chunksize)
195195
pos = 0
196196
while pos < len(binary):
197-
m = _libc_search.search(binary,pos)
197+
if 'libc' in binary or 'GLIBC' in binary:
198+
m = _libc_search.search(binary, pos)
199+
else:
200+
m = None
198201
if not m or m.end() == len(binary):
199202
chunk = f.read(chunksize)
200203
if chunk:

0 commit comments

Comments
 (0)