Skip to content

Commit

Permalink
Remove implicit calling to tobytes (speedup) (fixup)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucduron committed Feb 26, 2024
1 parent 012d2bf commit eb055c6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pyteltools/slf/Serafin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,22 +1110,22 @@ def write_header(self, header):
# IKLE
nb_ikle_values = header.nb_elements * header.nb_nodes_per_elem
self.file.write(header.pack_int(4 * nb_ikle_values))
self.file.write(np.array(header.ikle, dtype=np.dtype(np.int32).newbyteorder(header.endian)).tobytes())
self.file.write(np.array(header.ikle, dtype=np.dtype(np.int32).newbyteorder(header.endian)))
self.file.write(header.pack_int(4 * nb_ikle_values))

# IPOBO
self.file.write(header.pack_int(4 * header.nb_nodes))
self.file.write(np.array(header.ipobo, dtype=np.dtype(np.int32).newbyteorder(header.endian)).tobytes())
self.file.write(np.array(header.ipobo, dtype=np.dtype(np.int32).newbyteorder(header.endian)))
self.file.write(header.pack_int(4 * header.nb_nodes))

# X coordinates
self.file.write(header.pack_int(header.float_size * header.nb_nodes))
self.file.write(np.array(header.x_stored, dtype=header.np_type).tobytes())
self.file.write(np.array(header.x_stored, dtype=header.np_type))
self.file.write(header.pack_int(header.float_size * header.nb_nodes))

# Y coordinates
self.file.write(header.pack_int(header.float_size * header.nb_nodes))
self.file.write(np.array(header.y_stored, dtype=header.np_type).tobytes())
self.file.write(np.array(header.y_stored, dtype=header.np_type))
self.file.write(header.pack_int(header.float_size * header.nb_nodes))

def write_entire_frame(self, header, time_to_write, values):
Expand All @@ -1144,5 +1144,5 @@ def write_entire_frame(self, header, time_to_write, values):

for i in range(header.nb_var):
self.file.write(header.pack_int(header.float_size * header.nb_nodes))
self.file.write(np.array(values[i, :], dtype=header.np_type).tobytes())
self.file.write(np.array(values[i, :], dtype=header.np_type))
self.file.write(header.pack_int(header.float_size * header.nb_nodes))

0 comments on commit eb055c6

Please sign in to comment.