Skip to content

feat: add copy and deepcopy methods to Unit and DType - #3870

Merged
jokasimr merged 3 commits into
mainfrom
add-copy
Apr 7, 2026
Merged

jokasimr merged 3 commits into
mainfrom
add-copy

Conversation

@jokasimr

Copy link
Copy Markdown
Contributor

Fixes #3865

@MridulS MridulS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but not sure about the deepcopy semantics while copying over things from cpp world to python.

@SimonHeybrock SimonHeybrock changed the title feat: add copy and deepcopy methods feat: add copy and deepcopy methods to Unit and DType Apr 7, 2026

@jl-wynen jl-wynen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but not sure about the deepcopy semantics while copying over things from cpp world to python.

It's ok. The lambdas return by value and therefore make a copy in the return statement. Plus, Unit and DType are immutable. So we strictly speaking don't even have to make a copy (at least in __copy__).

@jokasimr
jokasimr merged commit fe24674 into main Apr 7, 2026
4 checks passed
@jokasimr
jokasimr deleted the add-copy branch April 7, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement __copy__ and __deepcopy__ methods for scipp.Unit

3 participants