-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Singletonized 'Measure' and 'Reset' instructions and drafted a release note * Added singleton key functionality and test cases for Measure() and Reset() singleton instructions * Implemented corrections from review on test_singleton module
- Loading branch information
1 parent
af6fbd0
commit 7412951
Showing
6 changed files
with
79 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
releasenotes/notes/singletonize-instructions-78723f68cd0ac03f.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
features: | ||
- | | ||
The following standard library instructions are now instances of | ||
:class:`~.SingletonInstruction`: | ||
* :class:`~.Measure` | ||
* :class:`~.Reset` | ||
This means that if these classes are instantiated as (e.g.) ``Measure()`` using | ||
all the constructor defaults, they will all share a single global | ||
instance. This results in large reduction in the memory overhead for > 1 | ||
object of these types and significantly faster object construction time. | ||
upgrade: | ||
- | | ||
The following standard library instructions: | ||
* :class:`~.Measure` | ||
* :class:`~.Reset` | ||
are immutable, unless the attributes ``label``, ``duration`` and ``unit`` are given as keyword | ||
arguments during class construction. | ||
The attributes :attr:`~.Instruction.label`, :attr:`~.Instruction.duration`, :attr:`~.Instruction.unit`, | ||
and :attr:`~.Instruction.condition` attributes are all not publicly accessible and setting these attributes | ||
directly is not allowed and it will raise an exception. If they are needed for a particular | ||
instance you must ensure you have a mutable instance using :meth:`.Instruction.to_mutable` | ||
and use :meth:`.Instruction.c_if` for :attr:`~.Instruction.condition` | ||
For the singleton variant of these instructions, there is a special attribute | ||
:attr:`~.SingletonInstruction._singleton_lookup_key`, that when called generates a key based on the input | ||
arguments, which can be used for identifying and indexing these instructions within the framework. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters