diff --git a/electrum/_vendor/distutils/version.py b/electrum/_vendor/distutils/version.py index c33bebaed26a..dc4a2186af1d 100644 --- a/electrum/_vendor/distutils/version.py +++ b/electrum/_vendor/distutils/version.py @@ -327,7 +327,14 @@ def __str__ (self): def __repr__ (self): - return "LooseVersion ('%s')" % str(self) + # Fast path: avoid python's slow %-format and str() call + # Exploit that __str__ just returns self.vstring for LooseVersion + try: + s = self.vstring + except AttributeError: + s = str(self) + # This uses f-string, which is faster than % formatting + return f"LooseVersion ('{s}')" def _cmp (self, other):