From f40b69968ad9bbb8300b451640a82e1ac83aa7ba Mon Sep 17 00:00:00 2001 From: J08nY Date: Mon, 24 Jul 2023 18:41:32 +0200 Subject: Tiny performance improvements. --- pyecsca/ec/formula.py | 8 ++++---- pyecsca/ec/mod.py | 2 +- pyecsca/ec/op.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pyecsca/ec/formula.py b/pyecsca/ec/formula.py index 317788b..58978a7 100644 --- a/pyecsca/ec/formula.py +++ b/pyecsca/ec/formula.py @@ -375,15 +375,15 @@ class EFDFormula(Formula): ) self.code.append(CodeOp(code_module)) - @property + @cached_property def input_index(self): return 1 - @property + @cached_property def output_index(self): return max(self.num_inputs + 1, 3) - @property + @cached_property def inputs(self): return { var + str(i) @@ -392,7 +392,7 @@ class EFDFormula(Formula): ) } - @property + @cached_property def outputs(self): return { var + str(i) diff --git a/pyecsca/ec/mod.py b/pyecsca/ec/mod.py index a43db53..a974462 100644 --- a/pyecsca/ec/mod.py +++ b/pyecsca/ec/mod.py @@ -114,7 +114,7 @@ def miller_rabin(n: int, rounds: int = 50) -> bool: def _check(func): @wraps(func) def method(self, other): - if type(self) is not type(other): + if self.__class__ is not type(other): other = self.__class__(other, self.n) elif self.n != other.n: raise ValueError diff --git a/pyecsca/ec/op.py b/pyecsca/ec/op.py index b83562c..d948129 100644 --- a/pyecsca/ec/op.py +++ b/pyecsca/ec/op.py @@ -145,5 +145,5 @@ class CodeOp: def __call__(self, *args, **kwargs: Mod) -> Mod: """Execute this operation with :paramref:`.__call__.kwargs`.""" - exec(self.compiled, {}, kwargs) + exec(self.compiled, None, kwargs) return kwargs[self.result] -- cgit v1.2.3-70-g09d2