Created
April 11, 2025 01:16
-
-
Save grahamannett/11a27ae8a14cab59266efb235ade6967 to your computer and use it in GitHub Desktop.
cache getenv
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
| ❯ python -m timeit --setup "import os, functools; fn = functools.cache(lambda : os.getenv('PATH'))" -- "fn()" && python -m timeit --setup "import os; fn = lambda : os.getenv('PATH')" -- "fn()" | |
| 20000000 loops, best of 5: 19.9 nsec per loop | |
| 1000000 loops, best of 5: 342 nsec per loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment