diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b77a015..1da1d0c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Types of changes: - A github workflow for validating `CHANGELOG` updates in a PR ([#214](https://github.com/qBraid/pyqasm/pull/214)) ### Improved / Modified +- Added `slots=True` parameter to the data classes in `elements.py` to improve memory efficiency ([#218](https://github.com/qBraid/pyqasm/pull/218)) ### Deprecated diff --git a/src/pyqasm/elements.py b/src/pyqasm/elements.py index 6f9ebda7..3e4936c7 100644 --- a/src/pyqasm/elements.py +++ b/src/pyqasm/elements.py @@ -43,7 +43,7 @@ class Context(Enum): GATE = "gate" -@dataclass +@dataclass(slots=True) class DepthNode: """Base class for depth nodes.""" @@ -52,7 +52,7 @@ class DepthNode: depth: int = 0 -@dataclass +@dataclass(slots=True) class QubitDepthNode(DepthNode): """Qubit depth node.""" @@ -68,7 +68,7 @@ def is_idle(self) -> bool: return self._total_ops() == 0 -@dataclass +@dataclass(slots=True) class ClbitDepthNode(DepthNode): """Classical bit depth node.""" @@ -78,7 +78,7 @@ def is_idle(self) -> bool: return self.num_measurements == 0 -@dataclass +@dataclass(slots=True) class Variable: # pylint: disable=too-many-instance-attributes """ Class representing an OpenQASM variable.