Posts: 4,647
Threads: 1,494
Joined: Sep 2016
which is faster when arg1 is None?
code 1:
def fun1(arg1,arg2):
if arg1 is None:
return None
. . .
code 2:
def fun1(arg1,arg2):
if arg1 is None:
return arg1
. . .
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
are there any examples of timing python code in a script with
timeit?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
i'm getting about the same timing, plus or minus noise. i'll have to do the min() thing or look at the generated code (wondering how it loads that value). OTOH, if i can't tell the difference, then i guess it doesn't matter, even for a performance oriented person like me.
i wonder which is more
pythonic, loading a literal or a variable that was tested as being the same.
i once coded in IBM mainframe assembly, long, long ago, i even wrote code to do a 16-bit x 16-bit multiply to get a 32-bit result that ran faster than the mainframe's own CPU instruction that did the same thing.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.