我一年前写的这篇文章,我想知道是否有比我聪明得多的人能提出提高效率的建议。在
def tempcolor(mintemp=0,maxtemp=32,mincolor=44000,maxcolor=3200,ctemp=10,c=0):
tempdiff=(mincolor-maxcolor) / (maxtemp-mintemp)
ccolor=(ctemp-mintemp) * tempdiff
ctouse=(mincolor-ccolor)
#print ctouse
return ctouse;
有一系列的数字(mintemp到maxtemp)。调用ctouse时,我们计算比率,然后将相同的比率应用于其他数字范围(mincolor和maxcolor)。在
我在另一个脚本中使用它,只是想知道是否有人对如何使它更整洁有什么建议。或者更准确!在
谢谢
威尔
我假设你很少或者永远不会改变mintemp,maxtemp,mincolor,maxcolor的给定值。在
我所能看到的唯一的效率改进就是预先计算出这个比率
相关问题 更多 >
编程相关推荐