Skip to content

Replace int[] dictionary keys with a lower-allocation representation #11

Description

@hutchpd

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions