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

Open
#297 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp, numpy, python

Research direction

Start at dwave/optimization/_model.pyx around line 1729 and review ArraySymbol.state() alongside the NumPy interface constraints described here. Determine whether copy-on-write is feasible; otherwise consider a readonly return, while ensuring the node remains valid after model garbage collection. Done means state() avoids an unnecessary copy or safely returns readonly data without segfaults.

Written by the indexing model from the issue text.

Description

enhancement

I have copy-on-write on my mind. 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.

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.

Dominant language
C++
Stars
31
Forks
36
Avg merge
1d 9h
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dwavesystems/dwave-optimization

All issues in dwavesystems/dwave-optimization

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.