Skip to content

Commit

Permalink
Use memoryview in serialized cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Retribution98 committed Dec 13, 2023
1 parent 8d5ae13 commit 49ac4f3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions unidist/core/backends/mpi/core/local_object_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,9 @@ def cache_serialized_data(self, data_id, data):
"""
# We make a copy to avoid data corruption obtained through out-of-band serialization,
# and buffers are marked read-only to prevent them from being modified.
# `to_bytes()` call handles both points.
data["raw_buffers"] = [buf.tobytes() for buf in data["raw_buffers"]]
data["raw_buffers"] = [
memoryview(buf.tobytes()).toreadonly() for buf in data["raw_buffers"]
]
self._serialization_cache[data_id] = data
self.maybe_update_data_id_map(data_id)

Expand Down

0 comments on commit 49ac4f3

Please sign in to comment.