Skip to content

Instantly share code, notes, and snippets.

@eduardogpg
Created May 26, 2023 00:11
Show Gist options
  • Select an option

  • Save eduardogpg/0b0936a973f128bf5d3b8f67c762167a to your computer and use it in GitHub Desktop.

Select an option

Save eduardogpg/0b0936a973f128bf5d3b8f67c762167a to your computer and use it in GitHub Desktop.
import time
def simple_for():
lista = []
for x in range(0, 100_000_000):
lista.append(x)
def list_comprehension():
lista = [x for x in range(0, 100_000_000)]
start_time = time.time()
simple_for()
print("--- %s seconds ---" % (time.time() - start_time))
start_time = time.time()
list_comprehension()
print("--- %s seconds ---" % (time.time() - start_time))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment