Cache Path.is_dir calls#779
Conversation
Profiles of a `poetry lock --no-update` command are showing that this `Path.is_dir` call is both a hotspot (~0.8s out of a ~4.8s), and is regularly called with the same path multiple times (~1260 calls with ~440 unique paths): https://github.com/python-poetry/poetry-core/blob/1bdbd900c4fc1e2d4ed1ef15dfbcafdcb66dd892/src/poetry/core/packages/dependency.py#L364 Caching `Path.is_dir` trims roughly ~0.5s off of the time spent in `Path.is_dir` calls.
|
@ethantkoenig Out of interest: Is only |
With this change, |
Profiles of a
poetry lock --no-updatecommand (run on a closed-source repo I am unable to share) are showing that thisPath.is_dircall is a hotspot (~0.8s out of a ~4.8s), and calls are often made with the same path multiple times (~1260 calls with ~440 unique paths):poetry-core/src/poetry/core/packages/dependency.py
Line 364 in 1bdbd90
Caching
Path.is_dirtrims roughly ~0.5s off of the time spent inPath.is_dircalls.(I'm not familiar with this code, but the fact that
is_python_projectis already cached makes me assume that cachingPath.is_dircalls is also safe.)