Created
April 10, 2025 00:14
-
-
Save turicas/f28c110d931c437f5b952040ec2c1da1 to your computer and use it in GitHub Desktop.
Python tuple creation from list comprehesion is faster than from generator expression
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
#!/bin/bash | |
python -m timeit 'tuple(n for n in range(100))' | |
# Result: 100000 loops, best of 5: 2.09 usec per loop | |
python -m timeit 'tuple([n for n in range(100)])' | |
# Result: 200000 loops, best of 5: 1.13 usec per loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment