Skip to content

rehash: streamline executables discovery; fix regression#3418

Merged
native-api merged 16 commits intopyenv:masterfrom
native-api:fix-versions-rehash
Mar 7, 2026
Merged

rehash: streamline executables discovery; fix regression#3418
native-api merged 16 commits intopyenv:masterfrom
native-api:fix-versions-rehash

Conversation

@native-api
Copy link
Copy Markdown
Member

@native-api native-api commented Mar 7, 2026

Make sure you have checked all steps below.

Prerequisite

  • Please consider implementing the feature as a hook script or plugin as a first step.
    • pyenv has some powerful support for plugins and hook scripts. Please refer to Authoring plugins for details and try to implement it as a plugin if possible.
  • Please consider contributing the patch upstream to rbenv, since we have borrowed most of the code from that project.
    • We occasionally import the changes from rbenv. In general, you can expect changes made in rbenv will be imported to pyenv too, eventually.
    • Generally speaking, we prefer not to make changes in the core in order to keep compatibility with rbenv.
  • My PR addresses the following pyenv issue (if any)

Description

  • Here are some details about my PR

Fixes the regression by splitting the corner-cutting code for rehash into a dedicated branch.

Further saves some time:

exec "$(pyenv init - zsh)"
<empty fixture>
comparison (median)
  upstream: 101.1 ms
  working: 95.3 ms
  delta:    5.8 ms faster (5%)

<standard fixture>
comparison (median)
  upstream: 160.0 ms
  working: 116.3 ms
  delta:    43.7 ms faster (27%)

<large fixture>
comparison (median)
  upstream: 283.1 ms
  working: 150.9 ms
  delta:    132.2 ms faster (46%)

--------------------------------
exec "$(pyenv init - bash)"
<empty fixture>
comparison (median)
  upstream: 126.2 ms
  working: 118.5 ms
  delta:    7.6 ms faster (6%)

<standard fixture>
comparison (median)
  upstream: 351.0 ms
  working: 352.9 ms
  delta:    1.8 ms slower (0%)

<large fixture>
comparison (median)
  upstream: 473.2 ms
  working: 387.9 ms
  delta:    85.3 ms faster (18%)

Tests

  • My PR adds the following unit tests (if any)
    for the new switch

@native-api native-api requested review from a team as code owners March 7, 2026 05:53
@native-api native-api changed the title performance: streamline executable discovery for pyenv rehash; fix regression rehash: streamline executables discovery; fix regression Mar 7, 2026
This reverts commit b95891a.

Revert "[t] more debug info"

This reverts commit 6aec4c1.

Revert "[t] check sort version"

This reverts commit ce9ce2b.

Revert "[t] -irrelevant"

This reverts commit b85335f.

Revert "[t] print locale"

This reverts commit 75f906c.

Revert "[t] -irrelevant"

This reverts commit efd7c67.
[no ci]
@native-api native-api merged commit 8037f22 into pyenv:master Mar 7, 2026
@native-api native-api deleted the fix-versions-rehash branch March 7, 2026 10:09
@native-api
Copy link
Copy Markdown
Member Author

@jakelodwick I knew that corner cutting in the general case would bite us in the back at some point!
OTOH your profiling scripts came in clutch to ensure no performance degradation!

@jakelodwick
Copy link
Copy Markdown
Contributor

The readlink heuristic was too loose. I should have tested against pyenv-virtualenv's absolute symlinks. Thanks for the quick fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pyenv versions --bare --skip-aliases --skip-envs broken by 23bcdebe and includes envs

2 participants