Problem
The multi-qubit state representation appears to use int[] keys with structural comparison. This is flexible, but repeated cloning/grouping/copying of arrays may create allocation pressure during gate operations.
Why this matters
For small systems this is probably fine, but multi-qubit operations can grow quickly. Reducing allocations could improve performance and make the library scale better.
Suggested approach
Investigate alternatives such as:
- bit-packed integer/long keys for small qubit counts
- a readonly struct key
- pooled arrays
- immutable value-based basis state representation
This should probably start with measurement rather than immediate refactoring.
Acceptance criteria
- Add a benchmark or small performance test around repeated multi-qubit gate application.
- Compare current
int[] key behaviour against at least one alternative representation.
- Document findings before changing the core representation.
Problem
The multi-qubit state representation appears to use
int[]keys with structural comparison. This is flexible, but repeated cloning/grouping/copying of arrays may create allocation pressure during gate operations.Why this matters
For small systems this is probably fine, but multi-qubit operations can grow quickly. Reducing allocations could improve performance and make the library scale better.
Suggested approach
Investigate alternatives such as:
This should probably start with measurement rather than immediate refactoring.
Acceptance criteria
int[]key behaviour against at least one alternative representation.