相关疑难解决方法(0)

使用if-return-return或if-else-return更有效?

假设我有一个if声明return.从效率的角度来看,我应该使用

if(A > B):
    return A+1
return A-1
Run Code Online (Sandbox Code Playgroud)

要么

if(A > B):
    return A+1
else:
    return A-1
Run Code Online (Sandbox Code Playgroud)

在使用编译语言(C)或脚本语言(Python)时,我应该更喜欢一个还是另一个?

c python compiler-construction performance

115
推荐指数
5
解决办法
17万
查看次数

标签 统计

c ×1

compiler-construction ×1

performance ×1

python ×1