Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a generator to get bytes of pydicom.Datasets #78

Conversation

pchristos
Copy link
Contributor

in store_instances of DICOMwebClient.

The store_instances method accepts a set of DICOM frames, dumps them to bytes, and, finally, encodes them into a multipart/related request.

The above process results in storing the original DICOM frames in memory 3 times:

  1. as the original pydicom.Dataset instances passed into store_instances
  2. as bytes encoded in store_instances
  3. as the concatenation of the above bytes created in _encode_multipart_message

Using a generator in store_instances reduces memory footprint by 1/3, since the original pydicom.Datasets are dumped into bytes one by one while the multipart request body is being created by _encode_multipart_message.

in `store_instances` of `DICOMwebClient`.

The `store_instances` method accepts a set of DICOM frames, dumps
them to bytes, and, finally, encodes them into a multipart/related
request.

The above process results in storing the original DICOM frames in
memory 3 times:

1. as the original `pydicom.Dataset` instances passed
   into `store_instances`
2. as bytes encoded in `store_instances`
3. as the concatenation of the above bytes created in
   `_encode_multipart_message`

Using a generator in `store_instances` reduces memory footprint by
1/3, since the original `pydicom.Dataset`s are dumped into bytes
one by one while the multipart request body is being created by
`_encode_multipart_message`.
@hackermd hackermd added the enhancement New feature or request label Feb 18, 2023
@hackermd
Copy link
Collaborator

Thanks for your contribution @pchristos. Much appreciated. We will draft a new release and make a new version of the package available via pypi.

@hackermd hackermd merged commit e9c271a into ImagingDataCommons:master Feb 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants