中文版:我的Python代码运行速度较慢,如何优化代码以提高性能?例如使用列表推导式、避免不必要的循环、使用生成器等。

英文版:My Python code runs slowly. How can I optimize the code to improve performance? For example, using list comprehensions, avoiding unnecessary loops, using generators, etc.

该提示词已在以下工具中验证有效:ChatGPT、Claude、GitHub Copilot、Cursor、DeepSeek