一周优化内存、查询速度小结
1、能够使用map, reduce 或者filter的,就不要使用for循环
2、可以用数组广播计算,就用数组广播计算
3、
np.argsort(result[:,3])
np.argsort(result[:,3])
result[:,3]其实是进行了切片,就是对于所有行,取第四列,然后对第四列进行排序,排序得到了index,再使用array[index]即可
vec_dist.append(vec_enhanced)
reshape
np.fabs(vec1_temp-vec2_temp)
4、要有节省内存空间的意识
5、for i in a
a 可以为空,不会报错
6、判断空集
if not a :
print('empty')