Created
May 26, 2023 00:11
-
-
Save eduardogpg/0b0936a973f128bf5d3b8f67c762167a to your computer and use it in GitHub Desktop.
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
| 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