Skip to content

Commit

Permalink
Remove total_ordering from OptionKey
Browse files Browse the repository at this point in the history
It makes object initialisation slower...
  • Loading branch information
bruchar1 committed Feb 14, 2025
1 parent eb1aaf9 commit 7ee66f2
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions mesonbuild/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from __future__ import annotations
from collections import OrderedDict
from itertools import chain
from functools import total_ordering
import argparse
import dataclasses
import itertools
Expand Down Expand Up @@ -108,7 +107,6 @@ class ArgparseKWs(TypedDict, total=False):
_OptionKey__cache: T.Dict[T.Tuple[str, str, MachineChoice], OptionKey] = {}


@total_ordering
class OptionKey:

"""Represents an option key in the various option dictionaries.
Expand Down Expand Up @@ -185,6 +183,11 @@ def __eq__(self, other: object) -> bool:
return self._to_tuple() == other._to_tuple()
return NotImplemented

def __ne__(self, other: object) -> bool:
if isinstance(other, OptionKey):
return self._to_tuple() != other._to_tuple()
return NotImplemented

def __lt__(self, other: object) -> bool:
if isinstance(other, OptionKey):
if self.subproject is None:
Expand All @@ -194,6 +197,33 @@ def __lt__(self, other: object) -> bool:
return self._to_tuple() < other._to_tuple()
return NotImplemented

def __le__(self, other: object) -> bool:
if isinstance(other, OptionKey):
if self.subproject is None and other.subproject is not None:
return True
elif self.subproject is not None and other.subproject is None:
return False
return self._to_tuple() <= other._to_tuple()
return NotImplemented

def __gt__(self, other: object) -> bool:
if isinstance(other, OptionKey):
if other.subproject is None:
return self.subproject is not None
elif self.subproject is None:
return False
return self._to_tuple() > other._to_tuple()
return NotImplemented

def __ge__(self, other: object) -> bool:
if isinstance(other, OptionKey):
if self.subproject is None and other.subproject is not None:
return False
elif self.subproject is not None and other.subproject is None:
return True
return self._to_tuple() >= other._to_tuple()
return NotImplemented

def __str__(self) -> str:
out = self.name
if self.machine is MachineChoice.BUILD:
Expand Down

0 comments on commit 7ee66f2

Please sign in to comment.