python的性能1、Use xrange instead of range. 2、"".join(string) is better than + or += 3、while 1 is faster than while True 4、 list comphrension > for loop > while loop Use Map, Reduce and Filter instead of for loop where ever possible. 5、for checking 'a in b', dict or set is better than list/tuple. 6、if you need manipulations on both ends of a list, use deque. |
|
来自: java_laq小馆 > 《Python》