Skip to content

Commit 086e8c7

Browse files
committed
Merge branch 'main' of github.com:SpikeInterface/spikeinterface into prepare_release
2 parents 12f089b + 55c7de1 commit 086e8c7

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/spikeinterface/core/recording_tools.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,12 @@ def write_binary_recording(
131131
data_size_bytes = dtype_size_bytes * num_frames * num_channels
132132
file_size_bytes = data_size_bytes + byte_offset
133133

134-
file = open(file_path, "wb+")
135-
file.truncate(file_size_bytes)
136-
file.close()
134+
# Create an empty file with file_size_bytes
135+
with open(file_path, "wb+") as file:
136+
# 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+
137140
assert Path(file_path).is_file()
138141

139142
# use executor (loop or workers)

0 commit comments

Comments
 (0)