-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
coala is quite slow when showing version #2344
Comments
Thanks for reporting this issue! Your aid is required, fellow coalaian. Help us triage and solving this issue! CC @sils1297, @AbdealiJK |
Related: |
@hypothesist wanna profile it? :) |
oh why do we import all bears? :/ |
@sils1297 call graph? |
http://i.imgur.com/DIThpaY.jpg collecting bears is 50% |
HERE IS THE EVIL THING: inputs_group.add_argument(
'-b', '--bears', nargs='+', metavar='NAME',
help='names of bears to use').completer =\
ChoicesCompleter(get_all_bears_names()) the reason why every coala invocation takes a second even if it's only showing version |
And here's a ChoicesCompleter that works :) class ChoicesCompleter(object):
"""
This class is copied and adapted from
https://github.com/kislyuk/argcomplete.
"""
def __init__(self, choices):
self._choices = None
if callable(choices):
self._load_choices = (lambda self:
setattr(self, 'choices', choices()))
else:
self.choices = choices
def __call__(self, prefix, **kwargs):
return (c for c in self.choices if c.startswith(prefix))
@property
def choices(self):
if self._choices is None:
self._load_choices(self)
return self._choices
@choices.setter
def choices(self, iterable):
"""
Initialize the choices with items from the given iterable.
This also normalizes them to neat strings.
"""
self._choices = []
for choice in iterable:
if isinstance(choice, bytes):
choice = choice.decode(sys_encoding)
if not isinstance(choice, str):
choice = str(choice)
self._choices.append(choice) see also kislyuk/argcomplete#137 which is upstream. |
and the PR at kislyuk/argcomplete#138 |
This is because coala imports every bear and then runs the version command. This shouldn't happen^^
The text was updated successfully, but these errors were encountered: