I have seen a proliferation of deepcopy on Samples objects in Beacon-internal projects, and generally when I see deepcopy I think there's a missing copy method.
The internal use cases I have seen generally have the requirement that the data is copied, as well as the channels vector in the info object. E.g. you may want to copy, then perform an in-place montaging that updates the channels vector, and want the original unaffected.
That motivated the implementation here, where we shallow-copy each field of the SamplesInfo.
If we don't like this approach we could decide deepcopy is indeed the right approach for this. I benchmarked after implementing, and here deepcopy isn't that bad for performance (probably because it's mostly a big chunk of contiguous data, which Julia's serializer is optimized for):
I have seen a proliferation of
deepcopy
on Samples objects in Beacon-internal projects, and generally when I seedeepcopy
I think there's a missingcopy
method.The internal use cases I have seen generally have the requirement that the data is copied, as well as the
channels
vector in the info object. E.g. you may want tocopy
, then perform an in-place montaging that updates thechannels
vector, and want the original unaffected.That motivated the implementation here, where we shallow-copy each field of the
SamplesInfo
.If we don't like this approach we could decide
deepcopy
is indeed the right approach for this. I benchmarked after implementing, and heredeepcopy
isn't that bad for performance (probably because it's mostly a big chunk of contiguous data, which Julia's serializer is optimized for):