copy¶
Shallow and deep copy operations, similar to Python's copy module.
Functions¶
copy.copy(x: object) -> object¶
Return a shallow copy of x.
For Sharpy collections (List{T}, Dict{K,V},
Set{T}), a new collection is created with the same element
references. For value types the value is returned as-is. For other
reference types, MemberwiseClone is invoked via reflection.
Parameters:
x(object) -- The object to copy.
Returns: A shallow copy of x.
copy.deepcopy(x: object) -> object¶
Return a deep copy of x. For Sharpy collections, elements are recursively deep-copied. An identity dictionary tracks already-copied objects to handle circular references. For non-collection objects, falls back to a shallow copy.
Parameters:
x(object) -- The object to deep-copy.
Returns: A deep copy of x.