my_first_calculator.py icon indicating copy to clipboard operation
my_first_calculator.py copied to clipboard

Increase efficiency trough the replacement of if with elif statements.

Open leyyce opened this issue 5 years ago • 1 comments

Although I know that this probably already is the most efficient calculator ever written by intelligent life forms, I belive that we could make it even more efficient trough replacing the if statements after the first calculation with elif statements to reduce execution overhead that happens when checking if conditions that can't possibly be true anymore.

Because the code is already so efficient I don't belive that this change will bring a noticeable performance increase but it's good prarice anyway so we should implement it.

leyyce avatar Nov 16 '19 13:11 leyyce

Okay just saw the comment in generator.py but I will keep working on a way to circumvent the recursive error. Maybe starting every big if block for a certain mathematical operation with a new if and replacing the rest with elif could work?

leyyce avatar Nov 16 '19 13:11 leyyce