@classmethod
    def pack(cls, val, str_cache, object_cache, traits_cache):
        if object_cache in val:
            index = object_cache.index(val)
            return AMF3Integer(index << 1)
        else:
            object_cache.append(val)
            chunks = []

            if isinstance(val, AMF3Array):
                dense_keys = val.dense_keys()
                length = len(dense_keys)
            else:
                length = len(val)
                dense_keys = list(range(length))

            header = length << 1 | 1
            chunks.append(AMF3Integer(header))

            if isinstance(val, AMF3Array):
                for key, value in val.items():
                    if key in dense_keys:
                        continue

                    chunks.append(AMF3String(key, cache=str_cache))

                    value = AMF3Value.pack(value, str_cache=str_cache,
                                           object_cache=object_cache,
                                           traits_cache=traits_cache)
                    chunks.append(value)

            # Empty string is end of dynamic values
            chunks.append(U8(AMF3_CLOSE_DYNAMIC_ARRAY))

            for key in dense_keys:
                value = val[key]
                value = AMF3Value.pack(value, str_cache=str_cache,
                                       object_cache=object_cache,
                                       traits_cache=traits_cache)
                chunks.append(value)

            return b"".join(chunks)
dataset/ETHPy150Open chrippa/livestreamer/src/livestreamer/packages/flashmedia/types.py/AMF3ArrayPacker.pack/swapped operands of `in`