def METHOD_NAME(protocol):
    if protocol[:1] == b'M':
        from msgpack import unpackb
        def msgpack_decode(data):
            """Decodes msg and returns its parts"""
            return unpackb(data, raw=False, use_list=False)
        return msgpack_decode
    else:
        assert protocol[:1] == b'Z'
        return pickle_decode