Simplify `pack_frames_prelude`
* Simplify `pack_frames_prelude`
Reduce to a single line of code.
* Assign variables to clarify meaning
@@ -91,10 +91,9 @@ def merge_frames(header, frames):
def pack_frames_prelude(frames):
- lengths = [struct.pack("Q", len(frames))] + [
- struct.pack("Q", nbytes(frame)) for frame in frames
- ]
- return b"".join(lengths)
+ nframes = len(frames)
+ nbytes_frames = map(nbytes, frames)
+ return struct.pack(f"Q{nframes}Q", nframes, *nbytes_frames)
def pack_frames(frames):
