【收集】Python 微优化
生活随笔
收集整理的這篇文章主要介紹了
【收集】Python 微优化
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1. 第二種方式可以節省尋找result的append屬性的時間, 但會降低代碼可讀性和可維護性
# The way we're used to seeing it: result.append("hello")# But this works the same: append_result = result.append append_result("hello")?
2. 將Python內置的方法在函數內重命名:尋找局部變量快于尋找全局變量和內置變量
# -*- coding:utf-8 -*- # local to a function, global to a module, or built-in to Python to_str = str?
轉載于:https://www.cnblogs.com/pengyusong/p/5981199.html
總結
以上是生活随笔為你收集整理的【收集】Python 微优化的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: HDOJ 5071 Chat 模拟
- 下一篇: 从零开始学习Qt GUI编程