MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / deepcopy_minimal

Function deepcopy_minimal

src/opencode_ai/_utils/_utils.py:180–192  ·  view source on GitHub ↗

Minimal reimplementation of copy.deepcopy() that will only copy certain object types: - mappings, e.g. `dict` - list This is done for performance reasons.

(item: _T)

Source from the content-addressed store, hash-verified

178
179
180def deepcopy_minimal(item: _T) -> _T:
181 """Minimal reimplementation of copy.deepcopy() that will only copy certain object types:
182
183 - mappings, e.g. `dict`
184 - list
185
186 This is done for performance reasons.
187 """
188 if is_mapping(item):
189 return cast(_T, {k: deepcopy_minimal(v) for k, v in item.items()})
190 if is_list(item):
191 return cast(_T, [deepcopy_minimal(entry) for entry in item])
192 return item
193
194
195# copied from https://github.com/Rapptz/RoboDanny

Callers 6

test_simple_dictFunction · 0.90
test_nested_dictFunction · 0.90
test_complex_nested_dictFunction · 0.90
test_simple_listFunction · 0.90
test_nested_listFunction · 0.90
test_ignores_other_typesFunction · 0.90

Calls 2

is_mappingFunction · 0.85
is_listFunction · 0.85

Tested by 6

test_simple_dictFunction · 0.72
test_nested_dictFunction · 0.72
test_complex_nested_dictFunction · 0.72
test_simple_listFunction · 0.72
test_nested_listFunction · 0.72
test_ignores_other_typesFunction · 0.72