Skip to content
Permalink
Browse files

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 ba7c226)
  • Loading branch information...
vstinner committed Dec 3, 2018
1 parent c275be5 commit 8687bd86e6f138ef0699a1e9f3f9555765949b51
Showing with 4 additions and 1 deletion.
  1. +4 −1 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:

0 comments on commit 8687bd8

Please sign in to comment.
You can’t perform that action at this time.