def encode(self, obj):
        if self._is_valid_mysql_bigint(obj):
            return obj, 'i'

        value = pickle.dumps(obj, pickle.HIGHEST_PROTOCOL)
        value_type = 'p'
        if (
            self._compress_min_length and
            len(value) >= self._compress_min_length
        ):
            value = zlib.compress(value, self._compress_level)
            value_type = 'z'
        return value, value_type
Take a Python object and return it as a tuple (value, value_type), a
dataset/ETHPy150Open adamchainz/django-mysql/django_mysql/cache.py/MySQLCache.encode