import io

# Data Formats
BINN_OBJECT = b'\xe2'

BINN_STRING = b'\xa0'

def _int_to_bytes(value):
    return value.to_bytes(1, 'big')

def dumps(value, bytes_io=None):
    value_type = type(value)
    size = 0
    count = 0

    # String
    if value_type is str:
        size = len(value.encode('utf8'))
        # Store the type
        bytes_io.write(BINN_STRING)
        # Store the size
        bytes_io.write(_int_to_bytes(size))
        # Store the string
        bytes_io.write(value.encode('utf8') + b'\0')        
        return None

    # Dictionary
    if value_type is dict:

        dict_bytes_io = io.BytesIO()
        bytes_io = io.BytesIO()

        # Store the dict type
        bytes_io.write(BINN_OBJECT)

        count = len(value)

        for key in value:
            # Store the key
            size = len(key.encode('utf8'))
            if size > 255:
                raise OverflowError("Key '{}' is to long".format(key))
            dict_bytes_io.write(_int_to_bytes(size))
            dict_bytes_io.write(key.encode('utf8'))
            dumps(value[key], dict_bytes_io)
        
        # Calculate container size + 3 bytes for: type, container size and key/value pairs
        size = dict_bytes_io.tell() + 3

        # Store container size
        bytes_io.write(_int_to_bytes(size))
        # Store key/value pairs
        bytes_io.write(_int_to_bytes(count))
        # Store content
        bytes_io.write(dict_bytes_io.getvalue())

        return bytes_io.getvalue()

    raise NotImplementedError("Not supported type: {}".format(value_type))

def loads(buffer):
    return None
@@ -87,24 +87,98 @@
 tes(value):%0A
+    if value %3E 127:%0A        return (value %7C 0x80000000).to_bytes(4,'big')%0A
     return v
@@ -1257,32 +1257,40 @@
  key/value pairs
+        
 %0A        size = 
@@ -1313,16 +1313,107 @@
 ll() + 3
+%0A        if count %3E 127:%0A            size += 3%0A        if size %3E 127:%0A            size += 3
 %0A%0A      

Handle big sizes