MCPcopy Create free account
hub / github.com/apache/tvm-ffi / _make_copy

Function _make_copy

python/tvm_ffi/_dunder.py:166–181  ·  view source on GitHub ↗

Build ``__copy__`` with ``__ffi_shallow_copy__`` resolved at install time.

(type_info: TypeInfo, shallow_copy_fn: Function | None)

Source from the content-addressed store, hash-verified

164
165
166def _make_copy(type_info: TypeInfo, shallow_copy_fn: Function | None) -> Callable[..., Any]:
167 """Build ``__copy__`` with ``__ffi_shallow_copy__`` resolved at install time."""
168 if shallow_copy_fn is not None:
169
170 def __copy__(self: Any) -> Any:
171 return shallow_copy_fn(self)
172
173 else:
174
175 def __copy__(self: Any) -> Any:
176 raise TypeError(
177 f"Type `{type(self).__name__}` does not support copy. "
178 f"The underlying C++ type is not copy-constructible."
179 )
180
181 return __copy__
182
183
184def _make_deepcopy(_type_info: TypeInfo) -> Callable[..., Any]:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected