From fa26844f671d62ad0c8a23ed89a41d6415b560f7 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 22 Apr 2019 16:25:42 -0700 Subject: [PATCH] mesonlib: specialize the implementation of == and != Instead of using the ___cmp__ method just straight up compare the two values, since we've already converted numbers to ints and split non-numeric seperators this is sufficient, and 4x faster --- mesonbuild/mesonlib.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 2beeae7f3..7b9aa1e4b 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -530,7 +530,14 @@ class Version: return self.__cmp__(other) == -1 def __eq__(self, other): - return self.__cmp__(other) == 0 + if isinstance(other, Version): + return self._v == other._v + return NotImplemented + + def __ne__(self, other): + if isinstance(other, Version): + return self._v != other._v + return NotImplemented def __cmp__(self, other): def cmp(a, b):