In python how to skip a function call if the same parameters were used before?