Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Performance python中if-else语句的性能如何_Performance_Python 2.7 - Fatal编程技术网

Performance python中if-else语句的性能如何

Performance python中if-else语句的性能如何,performance,python-2.7,Performance,Python 2.7,我在python代码中使用if-else。我想知道还有多少如果我可以添加而不影响我的脚本性能 在if-else语句的数量之后,我的脚本的性能下降了???它们的数量其实并不重要。这是什么在他们里面,将决定性能。计算if-else语句所需的时间非常少。此外,编译器还使用了一些技巧使其速度更快,因此您真的不必担心它。如果您注意到脚本速度慢,请提问。就目前而言,唯一的答案是,总体而言,这不太可能是一个性能问题。然而,这可能是一个糟糕的设计选择。我觉得你可能想用字典。。。但是,如果不知道更多的细节,就不可

我在python代码中使用if-else。我想知道还有多少如果我可以添加而不影响我的脚本性能


在if-else语句的数量之后,我的脚本的性能下降了???

它们的数量其实并不重要。这是什么在他们里面,将决定性能。计算if-else语句所需的时间非常少。此外,编译器还使用了一些技巧使其速度更快,因此您真的不必担心它。

如果您注意到脚本速度慢,请提问。就目前而言,唯一的答案是,总体而言,这不太可能是一个性能问题。然而,这可能是一个糟糕的设计选择。我觉得你可能想用字典。。。但是,如果不知道更多的细节,就不可能说出更有用的话。我一点线索也没有。为什么不做一些实验,告诉我们——在性能下降之前,您可以向脚本中添加多少if语句?一般来说,如果
elif
语句影响您的性能,那么您的应用程序对性能不敏感。