Skip to content

Instantly share code, notes, and snippets.

@xcombelle
Last active May 8, 2023 07:57
Show Gist options
  • Save xcombelle/8ac84ccb276f8996ed1a458ee2b3efa7 to your computer and use it in GitHub Desktop.
Save xcombelle/8ac84ccb276f8996ed1a458ee2b3efa7 to your computer and use it in GitHub Desktop.
global variable impact
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()
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