yyuu/pyenv — pull request #129 by blueyed (2014-03-13 14:13:13+00:00)
Title: Optimize pyenv-which: implement remove_from_path in Bash

This greatly improves the performance of `pyenv virtualenvwrapper_lazy`,
which happens to call pyenv-which a lot.

For profiling I've initially used:

% zmodload zsh/zprof
% eval "$(pyenv init -)"
% pyenv virtualenvwrapper_lazy

Before:
% zprof|grep -E '(pyenv|virtualenv)'
1) 1 754,07 754,07 58,95% 751,50 751,50 58,75% pyenv
21) 1 2,57 2,57 0,20% 2,57 2,57 0,20% virtualenvwrapper_setup_lazy_loader
1) 1 754,07 754,07 58,95% 751,50 751,50 58,75% pyenv
1/1 2,57 2,57 0,20% 2,57 2,57 virtualenvwrapper_setup_lazy_loader [21]
1/1 2,57 2,57 0,20% 2,57 2,57 pyenv [1]
21) 1 2,57 2,57 0,20% 2,57 2,57 0,20% virtualenvwrapper_setup_lazy_loader

After:
% zprof|grep -E '(pyenv|virtualenv)'
1) 1 383,30 383,30 27,97% 380,88 380,88 27,79% pyenv
31) 1 2,42 2,42 0,18% 2,42 2,42 0,18% virtualenvwrapper_setup_lazy_loader
1) 1 383,30 383,30 27,97% 380,88 380,88 27,79% pyenv
1/1 2,42 2,42 0,18% 2,42 2,42 virtualenvwrapper_setup_lazy_loader [31]
1/1 2,42 2,42 0,18% 2,42 2,42 pyenv [1]
31) 1 2,42 2,42 0,18% 2,42 2,42 0,18% virtualenvwrapper_setup_lazy_loader

Fixes https://github.com/yyuu/pyenv-virtualenvwrapper/issues/13

Tests all pass, and got slightly quicker.

Before:
142 tests, 0 failures
bats/bin/bats test/*.bats 11,59s user 17,35s system 110% cpu 26,192 total

After:
142 tests, 0 failures
bats/bin/bats test/*.bats 10,49s user 16,23s system 110% cpu 24,251 total