python reversed space complexity