Created
December 28, 2018 06:37
-
-
Save idlesign/817fb27ef2433df0d10c628bed630a51 to your computer and use it in GitHub Desktop.
Python 3.7 string formatting variants speed measure
This file contains 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 | |
measure () { | |
local RES=$(python3.7 -m timeit -n 2000000 -s 'x=256' "$1" | cut -d ":" -f 2) | |
echo "$1 -> $RES" | |
} | |
measure 'str(x)' | |
measure 'f"{x}"' | |
measure '"%d" % x' | |
measure '"{0}".format(x)' |
Author
idlesign
commented
Dec 28, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment