LoginSignup
17
7

More than 5 years have passed since last update.

pyenv, rbenv の shims のオーバーヘッド

Last updated at Posted at 2017-05-31

Rubyist が pyenv を使うときに知っておいてほしいこと で、 「pyenv を Python をビルドするためだけに利用する方法」について紹介しました。

そこで「シェルを軽量化し、 shims も利用しないようにする事ができます。」と書いたのですが、具体的にコマンドを shims 経由で起動するオーバーヘッドについて紹介しておきます。

$ type python3
python3 は /Users/inada-n/pyenv/shims/python3 です

$ pyenv shell 3.6.1
$ python3 -VV
Python 3.6.1 (default, May 18 2017, 16:23:51)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]

$ time python3 -S -c 42

real    0m0.099s
user    0m0.043s
sys 0m0.048s

$ time python3 -S -c 42

real    0m0.105s
user    0m0.044s
sys 0m0.051s

$ export PATH=$PYENV_ROOT/versions/3.6.1/bin:$PATH
$ python3 -VV
Python 3.6.1 (default, May 18 2017, 16:23:51)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]

$ time python3 -S -c 42

real    0m0.023s
user    0m0.013s
sys 0m0.010s

$ time python3 -S -c 42

real    0m0.025s
user    0m0.014s
sys 0m0.010s

mac での python 自体の起動速度は 20ms 強 (Linuxだともっと早いのですが…) ですが、 shims を通すだけで 100ms 強に遅くなります。
この違いが気になるか気にならないかは人によると思いますが、気になる人は pyenv を使うときに shims を使わない運用を試してみるといいと思います。

17
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
7