Replace TLObject.on_send with the new .to_bytes()

This also replaces some int.to_bytes() calls with a faster
struct.pack (up to x4 faster). This approach is also around
x3 faster than creating a BinaryWriter just to serialize a
TLObject as bytes.
This commit is contained in:
Lonami Exo
2017-09-26 14:36:02 +02:00
parent 2bb26d6389
commit b83cd98ba0
5 changed files with 110 additions and 64 deletions

View File

@@ -110,7 +110,7 @@ class BinaryWriter:
def tgwrite_object(self, tlobject):
"""Writes a Telegram object"""
tlobject.on_send(self)
self.write(tlobject.to_bytes())
def tgwrite_vector(self, vector):
"""Writes a vector of Telegram objects"""