+ refactor notes

This commit is contained in:
Ivan Pozdeev 2026-04-29 07:37:02 +03:00
parent 006e79891b
commit adc9e5e2a1
No known key found for this signature in database
GPG key ID: FB6A628DCF06DCD7
2 changed files with 8 additions and 2 deletions

View file

@ -54,8 +54,12 @@ for version in "${versions[@]}"; do
exit 1
fi
# Calling pyenv-prefix is expensive. Only do so if the path doesn't exist.
# See https://github.com/pyenv/pyenv-virtualenv/pull/502
# In the vast majority of cases, there's a direct match and
# not spawning `pyenv-prefix' saves about half the invocation time
# with a signle argument which accumulates when called repeatedly
# (e.g. from `pyenv-virtualenvs').
# `pyenv-prefix' also does not have hooks to worry about.
# XXX: refactor the test into a shared module?
PYENV_PREFIX_PATH="${PYENV_ROOT}/versions/${version}"
if [[ ! -d "$PYENV_PREFIX_PATH" ]]; then
PYENV_PREFIX_PATH="$(pyenv-prefix "${version}")"

View file

@ -119,6 +119,8 @@ for env_path in "${version_dir_entries[@]}"; do
if [[ -z $skip_aliases ]]; then
print_version "${env_path#"${PYENV_ROOT}"/versions/}" "${env_path}"
fi
# Mimics the test from pyenv-virtualenv-prefix
# XXX: refactor itto a shared module ?
elif [[ -f "${env_path}/bin/activate" ]]; then
print_version "${env_path#"${PYENV_ROOT}"/versions/}" "${env_path}"
fi