Running `pipenv --completion` is very slow
See original GitHub issueRunning pipenv --completion
is consistently slow (it takes about 1 second to run), even after the command has been run multiple times and everything has been loaded into memory.
This means including eval $(pipenv --completion)
in a .bashrc
file makes the user wait for a second until the shell prompt comes up.
Describe your environment
- OS: Kubuntu 17.04
- Python version: 2.7.13
- Pipenv version: 9.0.1
My shell is bash.
Expected result
The command shouldn’t take so long to run.
Actual result
When running in bash, the command takes a whole second to run.
$ time pipenv --completion
_pipenv_completion() {
local IFS=$'\t'
COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \
COMP_CWORD=$COMP_CWORD \
_PIPENV_COMPLETE=complete-bash $1 ) )
return 0
}
complete -F _pipenv_completion -o default pipenv
real 0m0.987s
user 0m0.888s
sys 0m0.080s
Steps to replicate
Run time pipenv --completion
in a bash shell.
P.S. This is a great project.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:19
- Comments:31 (12 by maintainers)
Top Results From Across the Web
Is Python's pipenv slow? - Stack Overflow
Yes, I've found pipenv's locking and dependency resolution is terrible. For what it's worth, I've moved to just venv and poetry.
Read more >Running `pipenv --completion` is very slow - Bountysource
Running `pipenv --completion` is very slow.
Read more >pipenv Documentation
Pipenv is a tool that aims to bring the best of all packaging worlds (bundler, composer, npm, cargo, yarn, etc.) to the. Python...
Read more >How to Manage Python Dependencies with Virtual ...
Cd into a Pipenv virtual environment and open a terminal or command window. b.Run the following command to retrieve a list of python...
Read more >Pipenv and Poetry: Benchmarks & Ergonomics · JohnFraney.ca
Pipenv and Poetry are next-generation Python dependency management tools. ... Each of the commands is benchmarked using time , running on my ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, but I sort of wish click generated proper completions. 😃 There are tools which generate “proper” completions thereby saving every application developer the effort of knowing how it works, while still not recursively calling the tool itself for every little thing.
Anyway, not understanding how to write completions is one thing, not knowing how to install them is another.
But it does. The current completion simply executes pipenv every time you try to complete anything; this doesn’t need to be checked for updates to the completion definition…
Either way it does not stop the completion from being delivered in
data_files
toshare/bash-completion/completions
, which should work, and be upgraded, whether installed viasudo pip
(😢),pip install --user
(since https://github.com/scop/bash-completion/commit/1d25d72ca8633c19cb089dff447d08c531379c59 it will be loaded from~/.local
), orpython setup.py install --root="$package_manager_install_root"
. (It will not work for wheels, in which case oh well, you’re certainly not worse off than if you didn’t use data_files at all. Also IMHO wheels suck.)This would save on one initial call to pipenv on every single new interactive shell, which while not quite as significant as one call on every single
pipenv <TAB>
is still not insignificant. It’s why bash-completion created the idea of lazy-loaded completions and tries to encourage people to use that over the “COMPAT_DIR” in/etc/bash_completion.d
.In the ideal case, users do not know, because it is automagically handled by developers or distro packagers. For example, https://git.archlinux.org/svntogit/community.git/commit/trunk?h=packages/python-pipenv&id=484eec9eabad806654fea29801577dc2cbe4188a
…
At the very least, put your eval thing into the lazy-load directory, so it doesn’t execute on every single new shell init but only gets executed the first time you try to tab-complete this specific tool.
Also, even 0.4s is so slow.