# deepcopy_with_paths

> **Function** in `langsmith`

📖 [View in docs](https://reference.langchain.com/python/langsmith/_openapi_client/_files/deepcopy_with_paths)

Copy only the containers along the given paths.

Used to guard against mutation by extract_files without copying the entire structure.
Only dicts and lists that lie on a path are copied; everything else
is returned by reference.

For example, given paths=[["foo", "files", "file"]] and the structure:
    {
        "foo": {
            "bar": {"baz": {}},
            "files": {"file": <content>}
        }
    }
The root dict, "foo", and "files" are copied (they lie on the path).
"bar" and "baz" are returned by reference (off the path).

## Signature

```python
deepcopy_with_paths(
    item: _T,
    paths: Sequence[Sequence[str]],
) -> _T
```

---

[View source on GitHub](https://github.com/langchain-ai/langsmith-sdk/blob/687fc8d527a28504432f52bd08c75f2894c209fe/python/langsmith/_openapi_client/_files.py#L128)