We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 12f089b + 55c7de1 commit 086e8c7Copy full SHA for 086e8c7
1 file changed
src/spikeinterface/core/recording_tools.py
@@ -131,9 +131,12 @@ def write_binary_recording(
131
data_size_bytes = dtype_size_bytes * num_frames * num_channels
132
file_size_bytes = data_size_bytes + byte_offset
133
134
- file = open(file_path, "wb+")
135
- file.truncate(file_size_bytes)
136
- file.close()
+ # Create an empty file with file_size_bytes
+ with open(file_path, "wb+") as file:
+ # The previous implementation `file.truncate(file_size_bytes)` was slow on Windows (#3408)
137
+ file.seek(file_size_bytes - 1)
138
+ file.write(b"\0")
139
+
140
assert Path(file_path).is_file()
141
142
# use executor (loop or workers)
0 commit comments