This has several benefits:
- The message can be resent without re-calling bytes(),
which for some requests may be expensive.
- Converting requests to bytes early lets us detect
errors early, such as OverflowError on bad requests.
- Containers can't exceed 1044456 bytes so knowing their
length is important. This can now be done in O(1).
But also several drawbacks:
- If the object is modified the bytes won't reflect this.
This isn't an issue because it's only done for in msgs.
- Incoming messages can no longer be reconverted into
bytes but this was never needed anyway.
There's 12..1024 padding for the MTProto 2.0 protocol, and
the length of the message can be used to determine how much
must be read on rpc_results. However this random padding
can be safely ignored.
This simplifies the flow instead of having separate request/body
attributes, and also means that BinaryReader.tgread_object() can
be used without so many special cases.