From adc9e5e2a1b2e448e63188e63e54e41a6d2265e3 Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Wed, 29 Apr 2026 07:37:02 +0300 Subject: [PATCH] + refactor notes --- bin/pyenv-virtualenv-prefix | 8 ++++++-- bin/pyenv-virtualenvs | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/pyenv-virtualenv-prefix b/bin/pyenv-virtualenv-prefix index c565e6f..198096a 100755 --- a/bin/pyenv-virtualenv-prefix +++ b/bin/pyenv-virtualenv-prefix @@ -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}")" diff --git a/bin/pyenv-virtualenvs b/bin/pyenv-virtualenvs index 33b106c..8676574 100755 --- a/bin/pyenv-virtualenvs +++ b/bin/pyenv-virtualenvs @@ -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