from . import TLObject, GzipPacked
from ..extensions import BinaryWriter


class MessageContainer(TLObject):
    constructor_id = 0x73f1f8dc

    def __init__(self, messages):
        super().__init__()
        self.content_related = False
        self.messages = messages

    def to_bytes(self):
        # TODO Change this to delete the on_send from this class
        with BinaryWriter() as writer:
            writer.write_int(MessageContainer.constructor_id, signed=False)
            writer.write_int(len(self.messages))
            for m in self.messages:
                writer.write(m.to_bytes())

            return writer.get_bytes()

    @staticmethod
    def iter_read(reader):
        reader.read_int(signed=False)  # code
        size = reader.read_int()
        for _ in range(size):
            inner_msg_id = reader.read_long()
            inner_sequence = reader.read_int()
            inner_length = reader.read_int()
            yield inner_msg_id, inner_sequence, inner_length

@@ -1,12 +1,27 @@
+import struct%0A%0A
 from . impor
@@ -34,58 +34,8 @@
 ject
-, GzipPacked%0Afrom ..extensions import BinaryWriter
 %0A%0A%0Ac
@@ -268,209 +268,80 @@
     
-# TODO Change this to delete the on_send from this class%0A        with BinaryWriter() as writer:%0A            writer.write_int(MessageContainer.constructor_id, signed=False)%0A            writer.write_int(
+return struct.pack(%0A            '%3CIi', MessageContainer.constructor_id, 
 len(
@@ -354,28 +354,25 @@
 essages)
-)%0A  
+%0A
         
   for m 
@@ -367,114 +367,56 @@
     
-  for m in self.messages:%0A                writer.write(m.to_bytes())%0A%0A            return writer.get_byt
+) + b''.join(m.to_bytes() for m in self.messag
 es
-(
 )%0A%0A 

Remove BinaryWriter dependency on MessageContainer