Skip to content

Instantly share code, notes, and snippets.

@wimglenn
Created August 20, 2020 00:12
Show Gist options
  • Save wimglenn/c3565a1c2d09bf2670b8c78088b2f02e to your computer and use it in GitHub Desktop.
Save wimglenn/c3565a1c2d09bf2670b8c78088b2f02e to your computer and use it in GitHub Desktop.
# timing of pkgutil and importlib.resources loaders from https://github.com/wimglenn/resources-example
# Python 3.8.5 on linux
>>> from myapp.example2 import func as pkgutil_loader
>>> from myapp.example4 import func as importlib_resources_loader
>>> timeit importlib_resources_loader()
392 µs ± 329 ns per loop (mean ± std. dev. of 7 runs, 1000 loops each)
>>> timeit pkgutil_loader()
200 µs ± 230 ns per loop (mean ± std. dev. of 7 runs, 1000 loops each)
>>> timeit importlib_resources_loader()
391 µs ± 733 ns per loop (mean ± std. dev. of 7 runs, 1000 loops each)
>>> timeit pkgutil_loader()
200 µs ± 423 ns per loop (mean ± std. dev. of 7 runs, 1000 loops each)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment