Last active
May 8, 2023 07:57
-
-
Save xcombelle/8ac84ccb276f8996ed1a458ee2b3efa7 to your computer and use it in GitHub Desktop.
global variable impact
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(): | |
from time import time as t | |
t1=t() | |
for i in range(1_000_000_000): | |
if i == -1: | |
break | |
print(t()-t1) | |
t1=t() | |
MAGIC_NUMBER = -1 | |
for i in range(1_000_000_000): | |
if i == MAGIC_NUMBER: | |
break | |
print(t()-t1) | |
t1=t() | |
def number_matches(num: int) -> bool: | |
return num == -1 | |
for i in range(1_000_000_000): | |
if number_matches(i): | |
break | |
print(t()-t1) | |
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import time as t | |
t1=t() | |
for i in range(1_000_000_000): | |
if i == -1: | |
break | |
print(t()-t1) | |
t1=t() | |
MAGIC_NUMBER = -1 | |
for i in range(1_000_000_000): | |
if i == MAGIC_NUMBER: | |
break | |
print(t()-t1) | |
t1=t() | |
def number_matches(num: int) -> bool: | |
return num == -1 | |
for i in range(1_000_000_000): | |
if number_matches(i): | |
break | |
print(t()-t1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment