aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJ08nY2023-02-12 23:02:54 +0100
committerJ08nY2023-02-12 23:02:54 +0100
commitf11268d7cb7f8749312c3d85f37451ebf84649ae (patch)
tree016a77ccd504dec885711c0de3d93d4a9c456954
parenta08a052db35e9b940b33b57750c5addf0f66facd (diff)
downloadpyecsca-f11268d7cb7f8749312c3d85f37451ebf84649ae.tar.gz
pyecsca-f11268d7cb7f8749312c3d85f37451ebf84649ae.tar.zst
pyecsca-f11268d7cb7f8749312c3d85f37451ebf84649ae.zip
Add __slots__ to Mods.
-rw-r--r--pyecsca/ec/mod.py5
-rw-r--r--test/ec/test_mod.py3
2 files changed, 8 insertions, 0 deletions
diff --git a/pyecsca/ec/mod.py b/pyecsca/ec/mod.py
index 405ab19..63fabe2 100644
--- a/pyecsca/ec/mod.py
+++ b/pyecsca/ec/mod.py
@@ -147,6 +147,7 @@ class Mod:
x: Any
n: Any
+ __slots__ = ("x", "n")
def __new__(cls, *args, **kwargs):
if cls != Mod:
@@ -263,6 +264,7 @@ class RawMod(Mod):
x: int
n: int
+ __slots__ = ("x", "n")
def __new__(cls, *args, **kwargs):
return object.__new__(cls)
@@ -367,6 +369,7 @@ _mod_classes["python"] = RawMod
@public
class Undefined(Mod):
"""A special undefined element."""
+ __slots__ = ("x", "n")
def __new__(cls, *args, **kwargs):
return object.__new__(cls)
@@ -472,6 +475,7 @@ class SymbolicMod(Mod):
x: Expr
n: int
+ __slots__ = ("x", "n")
def __new__(cls, *args, **kwargs):
return object.__new__(cls)
@@ -580,6 +584,7 @@ if has_gmp:
x: gmpy2.mpz
n: gmpy2.mpz
+ __slots__ = ("x", "n")
def __new__(cls, *args, **kwargs):
return object.__new__(cls)
diff --git a/test/ec/test_mod.py b/test/ec/test_mod.py
index 7802e95..62022b0 100644
--- a/test/ec/test_mod.py
+++ b/test/ec/test_mod.py
@@ -176,6 +176,9 @@ class ModTests(TestCase):
"__hash__",
"__abstractmethods__",
"_abc_impl",
+ "__slots__",
+ "x",
+ "n"
):
continue
args = [5 for _ in range(meth.__code__.co_argcount - 1)]