2023-02-23 13:37:34 -08:00
|
|
|
from typing import Self
|
2020-10-16 19:00:50 -07:00
|
|
|
from abc import ABCMeta
|
2020-07-22 02:45:16 -07:00
|
|
|
import copy
|
|
|
|
|
|
|
|
|
|
|
|
class Copyable(metaclass=ABCMeta):
|
|
|
|
"""
|
|
|
|
Abstract class which adds .copy() and .deepcopy()
|
|
|
|
"""
|
|
|
|
__slots__ = ()
|
|
|
|
|
|
|
|
'''
|
|
|
|
---- Non-abstract methods
|
|
|
|
'''
|
2023-02-23 13:37:34 -08:00
|
|
|
def copy(self) -> Self:
|
2020-07-22 02:45:16 -07:00
|
|
|
"""
|
|
|
|
Return a shallow copy of the object.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
`copy.copy(self)`
|
|
|
|
"""
|
|
|
|
return copy.copy(self)
|
|
|
|
|
2023-02-23 13:37:34 -08:00
|
|
|
def deepcopy(self) -> Self:
|
2020-07-22 02:45:16 -07:00
|
|
|
"""
|
|
|
|
Return a deep copy of the object.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
`copy.deepcopy(self)`
|
|
|
|
"""
|
|
|
|
return copy.deepcopy(self)
|