From c63ed79c5f5b58acb3da492616bb3842ef8b6ff0 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sat, 12 Apr 2025 01:40:16 -0500 Subject: [PATCH] scripts: Prefer .a for single entry namedtuples - CsvInt.x -> CsvInt.a - CsvFloat.x -> CsvFloat.a - Rev.x -> Rev.a This matches CsvFrac.a (paired with CsvFrac.b), and avoids confusion with x/y variables such as Tile.x and Tile.y. The other contender was .v, since these are cs*v* related types, but sticking with .a gets the point across that the name really doesn't have any meaning. There's also some irony that we're forcing namedtuples to have meaningless names, but it is useful to have a quick accessor for the internal value. --- scripts/code.py | 76 ++++++++++----------- scripts/cov.py | 98 +++++++++++++-------------- scripts/csv.py | 162 ++++++++++++++++++++++----------------------- scripts/ctx.py | 76 ++++++++++----------- scripts/data.py | 76 ++++++++++----------- scripts/perf.py | 76 ++++++++++----------- scripts/perfbd.py | 76 ++++++++++----------- scripts/stack.py | 76 ++++++++++----------- scripts/structs.py | 76 ++++++++++----------- 9 files changed, 396 insertions(+), 396 deletions(-) diff --git a/scripts/code.py b/scripts/code.py index 0aa56710..d31ba8ec 100755 --- a/scripts/code.py +++ b/scripts/code.py @@ -34,54 +34,54 @@ SECTIONS = ['.text', '.rodata', '.data'] # integer fields -class CsvInt(co.namedtuple('CsvInt', 'x')): +class CsvInt(co.namedtuple('CsvInt', 'a')): __slots__ = () - def __new__(cls, x=0): - if isinstance(x, CsvInt): - return x - if isinstance(x, str): + def __new__(cls, a=0): + if isinstance(a, CsvInt): + return a + if isinstance(a, str): try: - x = int(x, 0) + a = int(a, 0) except ValueError: # also accept +-∞ and +-inf - if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = mt.inf - elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -mt.inf + if re.match('^\s*\+?\s*(?:∞|inf)\s*$', a): + a = mt.inf + elif re.match('^\s*-\s*(?:∞|inf)\s*$', a): + a = -mt.inf else: raise - if not (isinstance(x, int) or mt.isinf(x)): - x = int(x) - return super().__new__(cls, x) + if not (isinstance(a, int) or mt.isinf(a)): + a = int(a) + return super().__new__(cls, a) def __repr__(self): - return '%s(%r)' % (self.__class__.__name__, self.x) + return '%s(%r)' % (self.__class__.__name__, self.a) def __str__(self): - if self.x == mt.inf: + if self.a == mt.inf: return '∞' - elif self.x == -mt.inf: + elif self.a == -mt.inf: return '-∞' else: - return str(self.x) + return str(self.a) def __bool__(self): - return bool(self.x) + return bool(self.a) def __int__(self): - assert not mt.isinf(self.x) - return self.x + assert not mt.isinf(self.a) + return self.a def __float__(self): - return float(self.x) + return float(self.a) none = '%7s' % '-' def table(self): return '%7s' % (self,) def diff(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 diff = new - old if diff == +mt.inf: return '%7s' % '+∞' @@ -91,8 +91,8 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return '%+7d' % diff def ratio(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 if mt.isinf(new) and mt.isinf(old): return 0.0 elif mt.isinf(new): @@ -107,22 +107,22 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return (new-old) / old def __pos__(self): - return self.__class__(+self.x) + return self.__class__(+self.a) def __neg__(self): - return self.__class__(-self.x) + return self.__class__(-self.a) def __abs__(self): - return self.__class__(abs(self.x)) + return self.__class__(abs(self.a)) def __add__(self, other): - return self.__class__(self.x + other.x) + return self.__class__(self.a + other.a) def __sub__(self, other): - return self.__class__(self.x - other.x) + return self.__class__(self.a - other.a) def __mul__(self, other): - return self.__class__(self.x * other.x) + return self.__class__(self.a * other.a) def __truediv__(self, other): if not other: @@ -130,10 +130,10 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return self.__class__(+mt.inf) else: return self.__class__(-mt.inf) - return self.__class__(self.x // other.x) + return self.__class__(self.a // other.a) def __mod__(self, other): - return self.__class__(self.x % other.x) + return self.__class__(self.a % other.a) # code size results class CodeResult(co.namedtuple('CodeResult', [ @@ -507,17 +507,17 @@ def collect_code(obj_paths, *, # common folding/tabling/read/write code -class Rev(co.namedtuple('Rev', 'x')): +class Rev(co.namedtuple('Rev', 'a')): __slots__ = () # yes we need all of these because we're a namedtuple def __lt__(self, other): - return self.x > other.x + return self.a > other.a def __gt__(self, other): - return self.x < other.x + return self.a < other.a def __le__(self, other): - return self.x >= other.x + return self.a >= other.a def __ge__(self, other): - return self.x <= other.x + return self.a <= other.a def fold(Result, results, *, by=None, diff --git a/scripts/cov.py b/scripts/cov.py index 6715fd89..08322629 100755 --- a/scripts/cov.py +++ b/scripts/cov.py @@ -36,54 +36,54 @@ GCOV_PATH = ['gcov'] # integer fields -class CsvInt(co.namedtuple('CsvInt', 'x')): +class CsvInt(co.namedtuple('CsvInt', 'a')): __slots__ = () - def __new__(cls, x=0): - if isinstance(x, CsvInt): - return x - if isinstance(x, str): + def __new__(cls, a=0): + if isinstance(a, CsvInt): + return a + if isinstance(a, str): try: - x = int(x, 0) + a = int(a, 0) except ValueError: # also accept +-∞ and +-inf - if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = mt.inf - elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -mt.inf + if re.match('^\s*\+?\s*(?:∞|inf)\s*$', a): + a = mt.inf + elif re.match('^\s*-\s*(?:∞|inf)\s*$', a): + a = -mt.inf else: raise - if not (isinstance(x, int) or mt.isinf(x)): - x = int(x) - return super().__new__(cls, x) + if not (isinstance(a, int) or mt.isinf(a)): + a = int(a) + return super().__new__(cls, a) def __repr__(self): - return '%s(%r)' % (self.__class__.__name__, self.x) + return '%s(%r)' % (self.__class__.__name__, self.a) def __str__(self): - if self.x == mt.inf: + if self.a == mt.inf: return '∞' - elif self.x == -mt.inf: + elif self.a == -mt.inf: return '-∞' else: - return str(self.x) + return str(self.a) def __bool__(self): - return bool(self.x) + return bool(self.a) def __int__(self): - assert not mt.isinf(self.x) - return self.x + assert not mt.isinf(self.a) + return self.a def __float__(self): - return float(self.x) + return float(self.a) none = '%7s' % '-' def table(self): return '%7s' % (self,) def diff(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 diff = new - old if diff == +mt.inf: return '%7s' % '+∞' @@ -93,8 +93,8 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return '%+7d' % diff def ratio(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 if mt.isinf(new) and mt.isinf(old): return 0.0 elif mt.isinf(new): @@ -109,22 +109,22 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return (new-old) / old def __pos__(self): - return self.__class__(+self.x) + return self.__class__(+self.a) def __neg__(self): - return self.__class__(-self.x) + return self.__class__(-self.a) def __abs__(self): - return self.__class__(abs(self.x)) + return self.__class__(abs(self.a)) def __add__(self, other): - return self.__class__(self.x + other.x) + return self.__class__(self.a + other.a) def __sub__(self, other): - return self.__class__(self.x - other.x) + return self.__class__(self.a - other.a) def __mul__(self, other): - return self.__class__(self.x * other.x) + return self.__class__(self.a * other.a) def __truediv__(self, other): if not other: @@ -132,10 +132,10 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return self.__class__(+mt.inf) else: return self.__class__(-mt.inf) - return self.__class__(self.x // other.x) + return self.__class__(self.a // other.a) def __mod__(self, other): - return self.__class__(self.x % other.x) + return self.__class__(self.a % other.a) # fractional fields, a/b class CsvFrac(co.namedtuple('CsvFrac', 'a,b')): @@ -150,7 +150,7 @@ class CsvFrac(co.namedtuple('CsvFrac', 'a,b')): return super().__new__(cls, CsvInt(a), CsvInt(b)) def __repr__(self): - return '%s(%r, %r)' % (self.__class__.__name__, self.a.x, self.b.x) + return '%s(%r, %r)' % (self.__class__.__name__, self.a.a, self.b.a) def __str__(self): return '%s/%s' % (self.a, self.b) @@ -169,12 +169,12 @@ class CsvFrac(co.namedtuple('CsvFrac', 'a,b')): return '%11s' % (self,) def notes(self): - if self.b.x == 0 and self.a.x == 0: + if self.b.a == 0 and self.a.a == 0: t = 1.0 - elif self.b.x == 0: - t = mt.copysign(mt.inf, self.a.x) + elif self.b.a == 0: + t = mt.copysign(mt.inf, self.a.a) else: - t = self.a.x / self.b.x + t = self.a.a / self.b.a return ['∞%' if t == +mt.inf else '-∞%' if t == -mt.inf else '%.1f%%' % (100*t)] @@ -189,8 +189,8 @@ class CsvFrac(co.namedtuple('CsvFrac', 'a,b')): def ratio(self, other): new_a, new_b = self if self else (CsvInt(0), CsvInt(0)) old_a, old_b = other if other else (CsvInt(0), CsvInt(0)) - new = new_a.x/new_b.x if new_b.x else 1.0 - old = old_a.x/old_b.x if old_b.x else 1.0 + new = new_a.a/new_b.a if new_b.a else 1.0 + old = old_a.a/old_b.a if old_b.a else 1.0 return new - old def __pos__(self): @@ -218,16 +218,16 @@ class CsvFrac(co.namedtuple('CsvFrac', 'a,b')): return self.__class__(self.a % other.a, self.b % other.b) def __eq__(self, other): - self_a, self_b = self if self.b.x else (CsvInt(1), CsvInt(1)) - other_a, other_b = other if other.b.x else (CsvInt(1), CsvInt(1)) + self_a, self_b = self if self.b.a else (CsvInt(1), CsvInt(1)) + other_a, other_b = other if other.b.a else (CsvInt(1), CsvInt(1)) return self_a * other_b == other_a * self_b def __ne__(self, other): return not self.__eq__(other) def __lt__(self, other): - self_a, self_b = self if self.b.x else (CsvInt(1), CsvInt(1)) - other_a, other_b = other if other.b.x else (CsvInt(1), CsvInt(1)) + self_a, self_b = self if self.b.a else (CsvInt(1), CsvInt(1)) + other_a, other_b = other if other.b.a else (CsvInt(1), CsvInt(1)) return self_a * other_b < other_a * self_b def __gt__(self, other): @@ -367,17 +367,17 @@ def collect_cov(gcda_paths, *, # common folding/tabling/read/write code -class Rev(co.namedtuple('Rev', 'x')): +class Rev(co.namedtuple('Rev', 'a')): __slots__ = () # yes we need all of these because we're a namedtuple def __lt__(self, other): - return self.x > other.x + return self.a > other.a def __gt__(self, other): - return self.x < other.x + return self.a < other.a def __le__(self, other): - return self.x >= other.x + return self.a >= other.a def __ge__(self, other): - return self.x <= other.x + return self.a <= other.a def fold(Result, results, *, by=None, diff --git a/scripts/csv.py b/scripts/csv.py index 41ae3b9c..59d3f16d 100755 --- a/scripts/csv.py +++ b/scripts/csv.py @@ -27,54 +27,54 @@ import sys # various field types # integer fields -class CsvInt(co.namedtuple('CsvInt', 'x')): +class CsvInt(co.namedtuple('CsvInt', 'a')): __slots__ = () - def __new__(cls, x=0): - if isinstance(x, CsvInt): - return x - if isinstance(x, str): + def __new__(cls, a=0): + if isinstance(a, CsvInt): + return a + if isinstance(a, str): try: - x = int(x, 0) + a = int(a, 0) except ValueError: # also accept +-∞ and +-inf - if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = mt.inf - elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -mt.inf + if re.match('^\s*\+?\s*(?:∞|inf)\s*$', a): + a = mt.inf + elif re.match('^\s*-\s*(?:∞|inf)\s*$', a): + a = -mt.inf else: raise - if not (isinstance(x, int) or mt.isinf(x)): - x = int(x) - return super().__new__(cls, x) + if not (isinstance(a, int) or mt.isinf(a)): + a = int(a) + return super().__new__(cls, a) def __repr__(self): - return '%s(%r)' % (self.__class__.__name__, self.x) + return '%s(%r)' % (self.__class__.__name__, self.a) def __str__(self): - if self.x == mt.inf: + if self.a == mt.inf: return '∞' - elif self.x == -mt.inf: + elif self.a == -mt.inf: return '-∞' else: - return str(self.x) + return str(self.a) def __bool__(self): - return bool(self.x) + return bool(self.a) def __int__(self): - assert not mt.isinf(self.x) - return self.x + assert not mt.isinf(self.a) + return self.a def __float__(self): - return float(self.x) + return float(self.a) none = '%7s' % '-' def table(self): return '%7s' % (self,) def diff(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 diff = new - old if diff == +mt.inf: return '%7s' % '+∞' @@ -84,8 +84,8 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return '%+7d' % diff def ratio(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 if mt.isinf(new) and mt.isinf(old): return 0.0 elif mt.isinf(new): @@ -100,22 +100,22 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return (new-old) / old def __pos__(self): - return self.__class__(+self.x) + return self.__class__(+self.a) def __neg__(self): - return self.__class__(-self.x) + return self.__class__(-self.a) def __abs__(self): - return self.__class__(abs(self.x)) + return self.__class__(abs(self.a)) def __add__(self, other): - return self.__class__(self.x + other.x) + return self.__class__(self.a + other.a) def __sub__(self, other): - return self.__class__(self.x - other.x) + return self.__class__(self.a - other.a) def __mul__(self, other): - return self.__class__(self.x * other.x) + return self.__class__(self.a * other.a) def __truediv__(self, other): if not other: @@ -123,59 +123,59 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return self.__class__(+mt.inf) else: return self.__class__(-mt.inf) - return self.__class__(self.x // other.x) + return self.__class__(self.a // other.a) def __mod__(self, other): - return self.__class__(self.x % other.x) + return self.__class__(self.a % other.a) # float fields -class CsvFloat(co.namedtuple('CsvFloat', 'x')): +class CsvFloat(co.namedtuple('CsvFloat', 'a')): __slots__ = () - def __new__(cls, x=0.0): - if isinstance(x, CsvFloat): - return x - if isinstance(x, str): + def __new__(cls, a=0.0): + if isinstance(a, CsvFloat): + return a + if isinstance(a, str): try: - x = float(x) + a = float(a) except ValueError: # also accept +-∞ and +-inf - if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = mt.inf - elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -mt.inf + if re.match('^\s*\+?\s*(?:∞|inf)\s*$', a): + a = mt.inf + elif re.match('^\s*-\s*(?:∞|inf)\s*$', a): + a = -mt.inf else: raise - if not isinstance(x, float): - x = float(x) - return super().__new__(cls, x) + if not isinstance(a, float): + a = float(a) + return super().__new__(cls, a) def __repr__(self): - return '%s(%r)' % (self.__class__.__name__, self.x) + return '%s(%r)' % (self.__class__.__name__, self.a) def __str__(self): - if self.x == mt.inf: + if self.a == mt.inf: return '∞' - elif self.x == -mt.inf: + elif self.a == -mt.inf: return '-∞' else: - return '%.1f' % self.x + return '%.1f' % self.a def __bool__(self): - return bool(self.x) + return bool(self.a) def __int__(self): - return int(self.x) + return int(self.a) def __float__(self): - return float(self.x) + return float(self.a) none = '%7s' % '-' def table(self): return '%7s' % (self,) def diff(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 diff = new - old if diff == +mt.inf: return '%7s' % '+∞' @@ -185,8 +185,8 @@ class CsvFloat(co.namedtuple('CsvFloat', 'x')): return '%+7.1f' % diff def ratio(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 if mt.isinf(new) and mt.isinf(old): return 0.0 elif mt.isinf(new): @@ -201,22 +201,22 @@ class CsvFloat(co.namedtuple('CsvFloat', 'x')): return (new-old) / old def __pos__(self): - return self.__class__(+self.x) + return self.__class__(+self.a) def __neg__(self): - return self.__class__(-self.x) + return self.__class__(-self.a) def __abs__(self): - return self.__class__(abs(self.x)) + return self.__class__(abs(self.a)) def __add__(self, other): - return self.__class__(self.x + other.x) + return self.__class__(self.a + other.a) def __sub__(self, other): - return self.__class__(self.x - other.x) + return self.__class__(self.a - other.a) def __mul__(self, other): - return self.__class__(self.x * other.x) + return self.__class__(self.a * other.a) def __truediv__(self, other): if not other: @@ -224,10 +224,10 @@ class CsvFloat(co.namedtuple('CsvFloat', 'x')): return self.__class__(+mt.inf) else: return self.__class__(-mt.inf) - return self.__class__(self.x / other.x) + return self.__class__(self.a / other.a) def __mod__(self, other): - return self.__class__(self.x % other.x) + return self.__class__(self.a % other.a) # fractional fields, a/b class CsvFrac(co.namedtuple('CsvFrac', 'a,b')): @@ -242,7 +242,7 @@ class CsvFrac(co.namedtuple('CsvFrac', 'a,b')): return super().__new__(cls, CsvInt(a), CsvInt(b)) def __repr__(self): - return '%s(%r, %r)' % (self.__class__.__name__, self.a.x, self.b.x) + return '%s(%r, %r)' % (self.__class__.__name__, self.a.a, self.b.a) def __str__(self): return '%s/%s' % (self.a, self.b) @@ -261,12 +261,12 @@ class CsvFrac(co.namedtuple('CsvFrac', 'a,b')): return '%11s' % (self,) def notes(self): - if self.b.x == 0 and self.a.x == 0: + if self.b.a == 0 and self.a.a == 0: t = 1.0 - elif self.b.x == 0: - t = mt.copysign(mt.inf, self.a.x) + elif self.b.a == 0: + t = mt.copysign(mt.inf, self.a.a) else: - t = self.a.x / self.b.x + t = self.a.a / self.b.a return ['∞%' if t == +mt.inf else '-∞%' if t == -mt.inf else '%.1f%%' % (100*t)] @@ -281,8 +281,8 @@ class CsvFrac(co.namedtuple('CsvFrac', 'a,b')): def ratio(self, other): new_a, new_b = self if self else (CsvInt(0), CsvInt(0)) old_a, old_b = other if other else (CsvInt(0), CsvInt(0)) - new = new_a.x/new_b.x if new_b.x else 1.0 - old = old_a.x/old_b.x if old_b.x else 1.0 + new = new_a.a/new_b.a if new_b.a else 1.0 + old = old_a.a/old_b.a if old_b.a else 1.0 return new - old def __pos__(self): @@ -310,16 +310,16 @@ class CsvFrac(co.namedtuple('CsvFrac', 'a,b')): return self.__class__(self.a % other.a, self.b % other.b) def __eq__(self, other): - self_a, self_b = self if self.b.x else (CsvInt(1), CsvInt(1)) - other_a, other_b = other if other.b.x else (CsvInt(1), CsvInt(1)) + self_a, self_b = self if self.b.a else (CsvInt(1), CsvInt(1)) + other_a, other_b = other if other.b.a else (CsvInt(1), CsvInt(1)) return self_a * other_b == other_a * self_b def __ne__(self, other): return not self.__eq__(other) def __lt__(self, other): - self_a, self_b = self if self.b.x else (CsvInt(1), CsvInt(1)) - other_a, other_b = other if other.b.x else (CsvInt(1), CsvInt(1)) + self_a, self_b = self if self.b.a else (CsvInt(1), CsvInt(1)) + other_a, other_b = other if other.b.a else (CsvInt(1), CsvInt(1)) return self_a * other_b < other_a * self_b def __gt__(self, other): @@ -1612,17 +1612,17 @@ def homogenize(Result, results, *, # common folding/tabling/read/write code -class Rev(co.namedtuple('Rev', 'x')): +class Rev(co.namedtuple('Rev', 'a')): __slots__ = () # yes we need all of these because we're a namedtuple def __lt__(self, other): - return self.x > other.x + return self.a > other.a def __gt__(self, other): - return self.x < other.x + return self.a < other.a def __le__(self, other): - return self.x >= other.x + return self.a >= other.a def __ge__(self, other): - return self.x <= other.x + return self.a <= other.a def fold(Result, results, *, by=None, diff --git a/scripts/ctx.py b/scripts/ctx.py index b9f5d31a..a8352aeb 100755 --- a/scripts/ctx.py +++ b/scripts/ctx.py @@ -30,54 +30,54 @@ OBJDUMP_PATH = ['objdump'] # integer fields -class CsvInt(co.namedtuple('CsvInt', 'x')): +class CsvInt(co.namedtuple('CsvInt', 'a')): __slots__ = () - def __new__(cls, x=0): - if isinstance(x, CsvInt): - return x - if isinstance(x, str): + def __new__(cls, a=0): + if isinstance(a, CsvInt): + return a + if isinstance(a, str): try: - x = int(x, 0) + a = int(a, 0) except ValueError: # also accept +-∞ and +-inf - if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = mt.inf - elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -mt.inf + if re.match('^\s*\+?\s*(?:∞|inf)\s*$', a): + a = mt.inf + elif re.match('^\s*-\s*(?:∞|inf)\s*$', a): + a = -mt.inf else: raise - if not (isinstance(x, int) or mt.isinf(x)): - x = int(x) - return super().__new__(cls, x) + if not (isinstance(a, int) or mt.isinf(a)): + a = int(a) + return super().__new__(cls, a) def __repr__(self): - return '%s(%r)' % (self.__class__.__name__, self.x) + return '%s(%r)' % (self.__class__.__name__, self.a) def __str__(self): - if self.x == mt.inf: + if self.a == mt.inf: return '∞' - elif self.x == -mt.inf: + elif self.a == -mt.inf: return '-∞' else: - return str(self.x) + return str(self.a) def __bool__(self): - return bool(self.x) + return bool(self.a) def __int__(self): - assert not mt.isinf(self.x) - return self.x + assert not mt.isinf(self.a) + return self.a def __float__(self): - return float(self.x) + return float(self.a) none = '%7s' % '-' def table(self): return '%7s' % (self,) def diff(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 diff = new - old if diff == +mt.inf: return '%7s' % '+∞' @@ -87,8 +87,8 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return '%+7d' % diff def ratio(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 if mt.isinf(new) and mt.isinf(old): return 0.0 elif mt.isinf(new): @@ -103,22 +103,22 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return (new-old) / old def __pos__(self): - return self.__class__(+self.x) + return self.__class__(+self.a) def __neg__(self): - return self.__class__(-self.x) + return self.__class__(-self.a) def __abs__(self): - return self.__class__(abs(self.x)) + return self.__class__(abs(self.a)) def __add__(self, other): - return self.__class__(self.x + other.x) + return self.__class__(self.a + other.a) def __sub__(self, other): - return self.__class__(self.x - other.x) + return self.__class__(self.a - other.a) def __mul__(self, other): - return self.__class__(self.x * other.x) + return self.__class__(self.a * other.a) def __truediv__(self, other): if not other: @@ -126,10 +126,10 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return self.__class__(+mt.inf) else: return self.__class__(-mt.inf) - return self.__class__(self.x // other.x) + return self.__class__(self.a // other.a) def __mod__(self, other): - return self.__class__(self.x % other.x) + return self.__class__(self.a % other.a) # ctx size results class CtxResult(co.namedtuple('CtxResult', [ @@ -720,17 +720,17 @@ def collect_ctx(obj_paths, *, # common folding/tabling/read/write code -class Rev(co.namedtuple('Rev', 'x')): +class Rev(co.namedtuple('Rev', 'a')): __slots__ = () # yes we need all of these because we're a namedtuple def __lt__(self, other): - return self.x > other.x + return self.a > other.a def __gt__(self, other): - return self.x < other.x + return self.a < other.a def __le__(self, other): - return self.x >= other.x + return self.a >= other.a def __ge__(self, other): - return self.x <= other.x + return self.a <= other.a def fold(Result, results, *, by=None, diff --git a/scripts/data.py b/scripts/data.py index afaed694..eaaa584b 100755 --- a/scripts/data.py +++ b/scripts/data.py @@ -34,54 +34,54 @@ SECTIONS = ['.data', '.bss'] # integer fields -class CsvInt(co.namedtuple('CsvInt', 'x')): +class CsvInt(co.namedtuple('CsvInt', 'a')): __slots__ = () - def __new__(cls, x=0): - if isinstance(x, CsvInt): - return x - if isinstance(x, str): + def __new__(cls, a=0): + if isinstance(a, CsvInt): + return a + if isinstance(a, str): try: - x = int(x, 0) + a = int(a, 0) except ValueError: # also accept +-∞ and +-inf - if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = mt.inf - elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -mt.inf + if re.match('^\s*\+?\s*(?:∞|inf)\s*$', a): + a = mt.inf + elif re.match('^\s*-\s*(?:∞|inf)\s*$', a): + a = -mt.inf else: raise - if not (isinstance(x, int) or mt.isinf(x)): - x = int(x) - return super().__new__(cls, x) + if not (isinstance(a, int) or mt.isinf(a)): + a = int(a) + return super().__new__(cls, a) def __repr__(self): - return '%s(%r)' % (self.__class__.__name__, self.x) + return '%s(%r)' % (self.__class__.__name__, self.a) def __str__(self): - if self.x == mt.inf: + if self.a == mt.inf: return '∞' - elif self.x == -mt.inf: + elif self.a == -mt.inf: return '-∞' else: - return str(self.x) + return str(self.a) def __bool__(self): - return bool(self.x) + return bool(self.a) def __int__(self): - assert not mt.isinf(self.x) - return self.x + assert not mt.isinf(self.a) + return self.a def __float__(self): - return float(self.x) + return float(self.a) none = '%7s' % '-' def table(self): return '%7s' % (self,) def diff(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 diff = new - old if diff == +mt.inf: return '%7s' % '+∞' @@ -91,8 +91,8 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return '%+7d' % diff def ratio(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 if mt.isinf(new) and mt.isinf(old): return 0.0 elif mt.isinf(new): @@ -107,22 +107,22 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return (new-old) / old def __pos__(self): - return self.__class__(+self.x) + return self.__class__(+self.a) def __neg__(self): - return self.__class__(-self.x) + return self.__class__(-self.a) def __abs__(self): - return self.__class__(abs(self.x)) + return self.__class__(abs(self.a)) def __add__(self, other): - return self.__class__(self.x + other.x) + return self.__class__(self.a + other.a) def __sub__(self, other): - return self.__class__(self.x - other.x) + return self.__class__(self.a - other.a) def __mul__(self, other): - return self.__class__(self.x * other.x) + return self.__class__(self.a * other.a) def __truediv__(self, other): if not other: @@ -130,10 +130,10 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return self.__class__(+mt.inf) else: return self.__class__(-mt.inf) - return self.__class__(self.x // other.x) + return self.__class__(self.a // other.a) def __mod__(self, other): - return self.__class__(self.x % other.x) + return self.__class__(self.a % other.a) # data size results class DataResult(co.namedtuple('DataResult', [ @@ -507,17 +507,17 @@ def collect_data(obj_paths, *, # common folding/tabling/read/write code -class Rev(co.namedtuple('Rev', 'x')): +class Rev(co.namedtuple('Rev', 'a')): __slots__ = () # yes we need all of these because we're a namedtuple def __lt__(self, other): - return self.x > other.x + return self.a > other.a def __gt__(self, other): - return self.x < other.x + return self.a < other.a def __le__(self, other): - return self.x >= other.x + return self.a >= other.a def __ge__(self, other): - return self.x <= other.x + return self.a <= other.a def fold(Result, results, *, by=None, diff --git a/scripts/perf.py b/scripts/perf.py index 99e76ee3..52d0b06c 100755 --- a/scripts/perf.py +++ b/scripts/perf.py @@ -44,54 +44,54 @@ THRESHOLD = (0.5, 0.85) # integer fields -class CsvInt(co.namedtuple('CsvInt', 'x')): +class CsvInt(co.namedtuple('CsvInt', 'a')): __slots__ = () - def __new__(cls, x=0): - if isinstance(x, CsvInt): - return x - if isinstance(x, str): + def __new__(cls, a=0): + if isinstance(a, CsvInt): + return a + if isinstance(a, str): try: - x = int(x, 0) + a = int(a, 0) except ValueError: # also accept +-∞ and +-inf - if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = mt.inf - elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -mt.inf + if re.match('^\s*\+?\s*(?:∞|inf)\s*$', a): + a = mt.inf + elif re.match('^\s*-\s*(?:∞|inf)\s*$', a): + a = -mt.inf else: raise - if not (isinstance(x, int) or mt.isinf(x)): - x = int(x) - return super().__new__(cls, x) + if not (isinstance(a, int) or mt.isinf(a)): + a = int(a) + return super().__new__(cls, a) def __repr__(self): - return '%s(%r)' % (self.__class__.__name__, self.x) + return '%s(%r)' % (self.__class__.__name__, self.a) def __str__(self): - if self.x == mt.inf: + if self.a == mt.inf: return '∞' - elif self.x == -mt.inf: + elif self.a == -mt.inf: return '-∞' else: - return str(self.x) + return str(self.a) def __bool__(self): - return bool(self.x) + return bool(self.a) def __int__(self): - assert not mt.isinf(self.x) - return self.x + assert not mt.isinf(self.a) + return self.a def __float__(self): - return float(self.x) + return float(self.a) none = '%7s' % '-' def table(self): return '%7s' % (self,) def diff(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 diff = new - old if diff == +mt.inf: return '%7s' % '+∞' @@ -101,8 +101,8 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return '%+7d' % diff def ratio(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 if mt.isinf(new) and mt.isinf(old): return 0.0 elif mt.isinf(new): @@ -117,22 +117,22 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return (new-old) / old def __pos__(self): - return self.__class__(+self.x) + return self.__class__(+self.a) def __neg__(self): - return self.__class__(-self.x) + return self.__class__(-self.a) def __abs__(self): - return self.__class__(abs(self.x)) + return self.__class__(abs(self.a)) def __add__(self, other): - return self.__class__(self.x + other.x) + return self.__class__(self.a + other.a) def __sub__(self, other): - return self.__class__(self.x - other.x) + return self.__class__(self.a - other.a) def __mul__(self, other): - return self.__class__(self.x * other.x) + return self.__class__(self.a * other.a) def __truediv__(self, other): if not other: @@ -140,10 +140,10 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return self.__class__(+mt.inf) else: return self.__class__(-mt.inf) - return self.__class__(self.x // other.x) + return self.__class__(self.a // other.a) def __mod__(self, other): - return self.__class__(self.x % other.x) + return self.__class__(self.a % other.a) # perf results class PerfResult(co.namedtuple('PerfResult', [ @@ -821,17 +821,17 @@ def collect_perf(perf_paths, *, # common folding/tabling/read/write code -class Rev(co.namedtuple('Rev', 'x')): +class Rev(co.namedtuple('Rev', 'a')): __slots__ = () # yes we need all of these because we're a namedtuple def __lt__(self, other): - return self.x > other.x + return self.a > other.a def __gt__(self, other): - return self.x < other.x + return self.a < other.a def __le__(self, other): - return self.x >= other.x + return self.a >= other.a def __ge__(self, other): - return self.x <= other.x + return self.a <= other.a def fold(Result, results, *, by=None, diff --git a/scripts/perfbd.py b/scripts/perfbd.py index cb15f848..d3043007 100755 --- a/scripts/perfbd.py +++ b/scripts/perfbd.py @@ -35,54 +35,54 @@ THRESHOLD = (0.5, 0.85) # integer fields -class CsvInt(co.namedtuple('CsvInt', 'x')): +class CsvInt(co.namedtuple('CsvInt', 'a')): __slots__ = () - def __new__(cls, x=0): - if isinstance(x, CsvInt): - return x - if isinstance(x, str): + def __new__(cls, a=0): + if isinstance(a, CsvInt): + return a + if isinstance(a, str): try: - x = int(x, 0) + a = int(a, 0) except ValueError: # also accept +-∞ and +-inf - if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = mt.inf - elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -mt.inf + if re.match('^\s*\+?\s*(?:∞|inf)\s*$', a): + a = mt.inf + elif re.match('^\s*-\s*(?:∞|inf)\s*$', a): + a = -mt.inf else: raise - if not (isinstance(x, int) or mt.isinf(x)): - x = int(x) - return super().__new__(cls, x) + if not (isinstance(a, int) or mt.isinf(a)): + a = int(a) + return super().__new__(cls, a) def __repr__(self): - return '%s(%r)' % (self.__class__.__name__, self.x) + return '%s(%r)' % (self.__class__.__name__, self.a) def __str__(self): - if self.x == mt.inf: + if self.a == mt.inf: return '∞' - elif self.x == -mt.inf: + elif self.a == -mt.inf: return '-∞' else: - return str(self.x) + return str(self.a) def __bool__(self): - return bool(self.x) + return bool(self.a) def __int__(self): - assert not mt.isinf(self.x) - return self.x + assert not mt.isinf(self.a) + return self.a def __float__(self): - return float(self.x) + return float(self.a) none = '%7s' % '-' def table(self): return '%7s' % (self,) def diff(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 diff = new - old if diff == +mt.inf: return '%7s' % '+∞' @@ -92,8 +92,8 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return '%+7d' % diff def ratio(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 if mt.isinf(new) and mt.isinf(old): return 0.0 elif mt.isinf(new): @@ -108,22 +108,22 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return (new-old) / old def __pos__(self): - return self.__class__(+self.x) + return self.__class__(+self.a) def __neg__(self): - return self.__class__(-self.x) + return self.__class__(-self.a) def __abs__(self): - return self.__class__(abs(self.x)) + return self.__class__(abs(self.a)) def __add__(self, other): - return self.__class__(self.x + other.x) + return self.__class__(self.a + other.a) def __sub__(self, other): - return self.__class__(self.x - other.x) + return self.__class__(self.a - other.a) def __mul__(self, other): - return self.__class__(self.x * other.x) + return self.__class__(self.a * other.a) def __truediv__(self, other): if not other: @@ -131,10 +131,10 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return self.__class__(+mt.inf) else: return self.__class__(-mt.inf) - return self.__class__(self.x // other.x) + return self.__class__(self.a // other.a) def __mod__(self, other): - return self.__class__(self.x % other.x) + return self.__class__(self.a % other.a) # perf results class PerfBdResult(co.namedtuple('PerfBdResult', [ @@ -795,17 +795,17 @@ def collect_perfbd(elf_path, trace_paths, *, # common folding/tabling/read/write code -class Rev(co.namedtuple('Rev', 'x')): +class Rev(co.namedtuple('Rev', 'a')): __slots__ = () # yes we need all of these because we're a namedtuple def __lt__(self, other): - return self.x > other.x + return self.a > other.a def __gt__(self, other): - return self.x < other.x + return self.a < other.a def __le__(self, other): - return self.x >= other.x + return self.a >= other.a def __ge__(self, other): - return self.x <= other.x + return self.a <= other.a def fold(Result, results, *, by=None, diff --git a/scripts/stack.py b/scripts/stack.py index 8c163943..322068b5 100755 --- a/scripts/stack.py +++ b/scripts/stack.py @@ -30,54 +30,54 @@ OBJDUMP_PATH = ['objdump'] # integer fields -class CsvInt(co.namedtuple('CsvInt', 'x')): +class CsvInt(co.namedtuple('CsvInt', 'a')): __slots__ = () - def __new__(cls, x=0): - if isinstance(x, CsvInt): - return x - if isinstance(x, str): + def __new__(cls, a=0): + if isinstance(a, CsvInt): + return a + if isinstance(a, str): try: - x = int(x, 0) + a = int(a, 0) except ValueError: # also accept +-∞ and +-inf - if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = mt.inf - elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -mt.inf + if re.match('^\s*\+?\s*(?:∞|inf)\s*$', a): + a = mt.inf + elif re.match('^\s*-\s*(?:∞|inf)\s*$', a): + a = -mt.inf else: raise - if not (isinstance(x, int) or mt.isinf(x)): - x = int(x) - return super().__new__(cls, x) + if not (isinstance(a, int) or mt.isinf(a)): + a = int(a) + return super().__new__(cls, a) def __repr__(self): - return '%s(%r)' % (self.__class__.__name__, self.x) + return '%s(%r)' % (self.__class__.__name__, self.a) def __str__(self): - if self.x == mt.inf: + if self.a == mt.inf: return '∞' - elif self.x == -mt.inf: + elif self.a == -mt.inf: return '-∞' else: - return str(self.x) + return str(self.a) def __bool__(self): - return bool(self.x) + return bool(self.a) def __int__(self): - assert not mt.isinf(self.x) - return self.x + assert not mt.isinf(self.a) + return self.a def __float__(self): - return float(self.x) + return float(self.a) none = '%7s' % '-' def table(self): return '%7s' % (self,) def diff(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 diff = new - old if diff == +mt.inf: return '%7s' % '+∞' @@ -87,8 +87,8 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return '%+7d' % diff def ratio(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 if mt.isinf(new) and mt.isinf(old): return 0.0 elif mt.isinf(new): @@ -103,22 +103,22 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return (new-old) / old def __pos__(self): - return self.__class__(+self.x) + return self.__class__(+self.a) def __neg__(self): - return self.__class__(-self.x) + return self.__class__(-self.a) def __abs__(self): - return self.__class__(abs(self.x)) + return self.__class__(abs(self.a)) def __add__(self, other): - return self.__class__(self.x + other.x) + return self.__class__(self.a + other.a) def __sub__(self, other): - return self.__class__(self.x - other.x) + return self.__class__(self.a - other.a) def __mul__(self, other): - return self.__class__(self.x * other.x) + return self.__class__(self.a * other.a) def __truediv__(self, other): if not other: @@ -126,10 +126,10 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return self.__class__(+mt.inf) else: return self.__class__(-mt.inf) - return self.__class__(self.x // other.x) + return self.__class__(self.a // other.a) def __mod__(self, other): - return self.__class__(self.x % other.x) + return self.__class__(self.a % other.a) # stack size results class StackResult(co.namedtuple('StackResult', [ @@ -463,17 +463,17 @@ def collect_stack(ci_paths, *, # common folding/tabling/read/write code -class Rev(co.namedtuple('Rev', 'x')): +class Rev(co.namedtuple('Rev', 'a')): __slots__ = () # yes we need all of these because we're a namedtuple def __lt__(self, other): - return self.x > other.x + return self.a > other.a def __gt__(self, other): - return self.x < other.x + return self.a < other.a def __le__(self, other): - return self.x >= other.x + return self.a >= other.a def __ge__(self, other): - return self.x <= other.x + return self.a <= other.a def fold(Result, results, *, by=None, diff --git a/scripts/structs.py b/scripts/structs.py index 0bcca318..dc63306a 100755 --- a/scripts/structs.py +++ b/scripts/structs.py @@ -30,54 +30,54 @@ OBJDUMP_PATH = ['objdump'] # integer fields -class CsvInt(co.namedtuple('CsvInt', 'x')): +class CsvInt(co.namedtuple('CsvInt', 'a')): __slots__ = () - def __new__(cls, x=0): - if isinstance(x, CsvInt): - return x - if isinstance(x, str): + def __new__(cls, a=0): + if isinstance(a, CsvInt): + return a + if isinstance(a, str): try: - x = int(x, 0) + a = int(a, 0) except ValueError: # also accept +-∞ and +-inf - if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = mt.inf - elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -mt.inf + if re.match('^\s*\+?\s*(?:∞|inf)\s*$', a): + a = mt.inf + elif re.match('^\s*-\s*(?:∞|inf)\s*$', a): + a = -mt.inf else: raise - if not (isinstance(x, int) or mt.isinf(x)): - x = int(x) - return super().__new__(cls, x) + if not (isinstance(a, int) or mt.isinf(a)): + a = int(a) + return super().__new__(cls, a) def __repr__(self): - return '%s(%r)' % (self.__class__.__name__, self.x) + return '%s(%r)' % (self.__class__.__name__, self.a) def __str__(self): - if self.x == mt.inf: + if self.a == mt.inf: return '∞' - elif self.x == -mt.inf: + elif self.a == -mt.inf: return '-∞' else: - return str(self.x) + return str(self.a) def __bool__(self): - return bool(self.x) + return bool(self.a) def __int__(self): - assert not mt.isinf(self.x) - return self.x + assert not mt.isinf(self.a) + return self.a def __float__(self): - return float(self.x) + return float(self.a) none = '%7s' % '-' def table(self): return '%7s' % (self,) def diff(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 diff = new - old if diff == +mt.inf: return '%7s' % '+∞' @@ -87,8 +87,8 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return '%+7d' % diff def ratio(self, other): - new = self.x if self else 0 - old = other.x if other else 0 + new = self.a if self else 0 + old = other.a if other else 0 if mt.isinf(new) and mt.isinf(old): return 0.0 elif mt.isinf(new): @@ -103,22 +103,22 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return (new-old) / old def __pos__(self): - return self.__class__(+self.x) + return self.__class__(+self.a) def __neg__(self): - return self.__class__(-self.x) + return self.__class__(-self.a) def __abs__(self): - return self.__class__(abs(self.x)) + return self.__class__(abs(self.a)) def __add__(self, other): - return self.__class__(self.x + other.x) + return self.__class__(self.a + other.a) def __sub__(self, other): - return self.__class__(self.x - other.x) + return self.__class__(self.a - other.a) def __mul__(self, other): - return self.__class__(self.x * other.x) + return self.__class__(self.a * other.a) def __truediv__(self, other): if not other: @@ -126,10 +126,10 @@ class CsvInt(co.namedtuple('CsvInt', 'x')): return self.__class__(+mt.inf) else: return self.__class__(-mt.inf) - return self.__class__(self.x // other.x) + return self.__class__(self.a // other.a) def __mod__(self, other): - return self.__class__(self.x % other.x) + return self.__class__(self.a % other.a) # struct size results class StructResult(co.namedtuple('StructResult', [ @@ -601,17 +601,17 @@ def collect_structs(obj_paths, *, # common folding/tabling/read/write code -class Rev(co.namedtuple('Rev', 'x')): +class Rev(co.namedtuple('Rev', 'a')): __slots__ = () # yes we need all of these because we're a namedtuple def __lt__(self, other): - return self.x > other.x + return self.a > other.a def __gt__(self, other): - return self.x < other.x + return self.a < other.a def __le__(self, other): - return self.x >= other.x + return self.a >= other.a def __ge__(self, other): - return self.x <= other.x + return self.a <= other.a def fold(Result, results, *, by=None,