Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
optimization
#1
if i code this:
bar = 0
if foo is None:
    bar = 99
elif foo is True:
    bar = 99
print(bar)
vs coding this:
bar = 0
if foo is None or foo is True:
    bar = 99
print(bar)
will CPython3 (whatever recent version you want to consider) produce the same compilation results whether optimization is in effect or not? if not, can you guess which will be faster? how extensive is the optimization?

what about coding this:
bar = 0
if foo is None:
    bar = 99
if foo is True:
    bar = 99
print(bar)
(elif changed to if), will this be any different?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020