An implementation of savepoints for Python, to avoid repeating expensive calculations