aboutsummaryrefslogtreecommitdiffhomepage
path: root/pyecsca/ec
diff options
context:
space:
mode:
authorJ08nY2023-07-24 18:41:32 +0200
committerJ08nY2023-07-24 18:41:32 +0200
commitf40b69968ad9bbb8300b451640a82e1ac83aa7ba (patch)
tree0d5bc2d6dbfe0434b9542e3fb2e68f572d95bd2a /pyecsca/ec
parent68dfba98f98e4839c3bd6a1ad3009e4eba6d59fb (diff)
downloadpyecsca-f40b69968ad9bbb8300b451640a82e1ac83aa7ba.tar.gz
pyecsca-f40b69968ad9bbb8300b451640a82e1ac83aa7ba.tar.zst
pyecsca-f40b69968ad9bbb8300b451640a82e1ac83aa7ba.zip
Tiny performance improvements.
Diffstat (limited to 'pyecsca/ec')
-rw-r--r--pyecsca/ec/formula.py8
-rw-r--r--pyecsca/ec/mod.py2
-rw-r--r--pyecsca/ec/op.py2
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]