quil-rs icon indicating copy to clipboard operation
quil-rs copied to clipboard

Can `Program.__add__`'s performance be improved?

Open asaites opened this issue 4 months ago • 0 comments

This is the current implementation of __add__ for a Program:

    fn __add__(&self, rhs: Self) -> Self {
        self.clone() + rhs
    }

Obviously this requires cloning both self and rhs (when it crosses the Python->Rust boundary), which is not ideal. We might be able to make use of rhs to avoid the clone.

Alternatively, we might be better off implementing __radd__ instead, but we should benchmark the difference to find out.

asaites avatar Aug 31 '25 18:08 asaites