From 3e5dc47fb1a212732efbc2a24b0e87fa5523d3e4 Mon Sep 17 00:00:00 2001 From: TheGupta2012 Date: Tue, 24 Jun 2025 13:06:13 +0530 Subject: [PATCH 1/2] add slots --- src/pyqasm/elements.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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. From 22055d9a77a12595cb951feea4a5bddaeae1c5ac Mon Sep 17 00:00:00 2001 From: TheGupta2012 Date: Tue, 24 Jun 2025 13:10:01 +0530 Subject: [PATCH 2/2] add changelog [no ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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