Skip to content

Instantly share code, notes, and snippets.

@geolimber
Last active December 8, 2018 05:26
Show Gist options
  • Save geolimber/64829303f3b1fb2f78ae9fd8f5868eb6 to your computer and use it in GitHub Desktop.
Save geolimber/64829303f3b1fb2f78ae9fd8f5868eb6 to your computer and use it in GitHub Desktop.
Just small perfomance test of map and list comp.
# map test without lambda
python3 -mtimeit -s'xs=range(10)' 'map(hex, xs)'
python3 -mtimeit -s'xs=range(10)' '[hex(x) for x in xs]'
# map lambda test
python3 -mtimeit -s'xs=range(10)' 'map(lambda x: x+2, xs)'
python3 -mtimeit -s'xs=range(10)' '[x+2 for x in xs]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment