def serialize(self):
"""Return the binary representation."""
io = BytesIO()
for k in self.keys():
try:
typecode = self.typecodes[k]
except KeyError:
typecode = None
io.write(serialize_component(k, self[k], typecode))
buf = io.getvalue()
return b''.join([
self.name.encode('utf-8'),
b'\0',
struct.pack('<I', len(buf)),
buf
])
评论列表
文章目录