ImagingDataCommons / highdicom

High-level DICOM abstractions for the Python programming language
https://highdicom.readthedocs.io
MIT License
164 stars 34 forks source link

Optionally skip deepcopy in `from_dataset` methods #207

Closed CPBridge closed 1 year ago

CPBridge commented 1 year ago

Tweaked all from_dataset methods to accept a new boolean copy parameter (default True) in order to skip the copy operation to improve performance. If False, the dataset parameter is altered in place. This is now used in the segread method, and dramatically improves the performance there.

@pieper this should cut around 25% off your large seg benchmark time based on my testing

CPBridge commented 1 year ago

Note also, there were previously a bunch of _from_dataset methods that did this but did not expose it publicly. In these cases I have essentially kept the same behaviour but now made it public via the copy parameter to the public from_dataset method. The result is a consistent API for all from_dataset methods in the library