Suppose that an API supports
y = calculate(a, x)
where a may or may not be modified by calculate, without affecting the x -> y mapping. For example, it could memoize results, collect statistics, etc.
Also, assume that calculate is not thread-safe, the intended usage is to make thread-local copies.
The question is whether there is a generic function one should use for that purpose, for which one would define a method for types that support calculate. One could define a method for Base.copy, but that’s not what it promises, it explicitly mentions a shallow copy. Base.deepcopy is too deep. Is there something in-between that is generally used?