dwavesystems / dwavesystems/dwave-optimization

Make array returned by `ArraySymbol.state()` copy-on-write

Open
#297 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
31
Forks
36
Avg merge
16h 55m
Merged PRs (30d)
8

Description

I have copy-on-write [on my mind](https://github.com/dwavesystems/dwave-optimization/issues/296). Now that I think about it, we should try to make the array returned by `ArraySymbol.state()` a copy-on-write array. Currently we [always return a copy](https://github.com/dwavesystems/dwave-optimization/blob/7335228aeb8492068a27b600ff2df0fb21f28b98/dwave/optimization/_model.pyx#L1729).

Of course, it might not be (easily) possible via NumPy's interface. In which case we should consider returning a readonly array.

Another challenge will be tying the lifespan of the node to the array. I.e. when the model gets garbage collected we don't want to segfault when accessing the array.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.