In Python, you can do:
b = bytearray(100) b[0:3] = 'one'.encode() b[17:20] = 'two'.encode() This, however, creates an intermediate bytes() object, which is leading to suboptimal performance.
Is there anything like encode_into() that will encode a string directly into a bytearray?