aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2019-04-22 16:25:42 -0700
committerDylan Baker <dylan@pnwbakers.com>2019-04-25 12:28:51 -0700
commitfa26844f671d62ad0c8a23ed89a41d6415b560f7 (patch)
treee1e8c049b9b06017a0d74399a476f69b8afd53b4 /mesonbuild/mesonlib.py
parent8977e49a9bddbd8078dd73315b5ef66375a511cd (diff)
downloadmeson-fa26844f671d62ad0c8a23ed89a41d6415b560f7.zip
meson-fa26844f671d62ad0c8a23ed89a41d6415b560f7.tar.gz
meson-fa26844f671d62ad0c8a23ed89a41d6415b560f7.tar.bz2
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
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r--mesonbuild/mesonlib.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 2beeae7..7b9aa1e 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):