MCPcopy
hub / github.com/pydantic/pydantic / __deepcopy__

Method __deepcopy__

pydantic/root_model.py:108–116  ·  view source on GitHub ↗

Returns a deep copy of the model.

(self, memo: dict[int, Any] | None = None)

Source from the content-addressed store, hash-verified

106 return m
107
108 def __deepcopy__(self, memo: dict[int, Any] | None = None) -> Self:
109 """Returns a deep copy of the model."""
110 cls = type(self)
111 m = cls.__new__(cls)
112 _object_setattr(m, '__dict__', deepcopy(self.__dict__, memo=memo))
113 # This next line doesn't need a deepcopy because __pydantic_fields_set__ is a set[str],
114 # and attempting a deepcopy would be marginally slower.
115 _object_setattr(m, '__pydantic_fields_set__', copy(self.__pydantic_fields_set__))
116 return m
117
118 if TYPE_CHECKING:
119

Callers

nothing calls this directly

Calls 1

__new__Method · 0.45

Tested by

no test coverage detected