Resize the internal buffer of bytearray to len. size New size to resize to.
>>> def resize(ba, size): ... if len(ba) > size: ... del ba[size:] ... else: ... ba += b'\0' * (size - len(ba))
builtins/bytearray.resize
bytearray.resize