Skip to content
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

rlcompleter on a heap is super expensive #9

Closed
zhuyifei1999 opened this issue Sep 20, 2019 · 0 comments
Closed

rlcompleter on a heap is super expensive #9

zhuyifei1999 opened this issue Sep 20, 2019 · 0 comments

Comments

@zhuyifei1999
Copy link
Owner

Not sure if this is fixable on our side, but I should document this:

$ python -i -c 'hp = __import__("guppy").hpy()'
>>> h = hp.heap()
>>> h.[TAB][TAB][HANGS]

GDB:

gef➤  py-bt
Traceback (most recent call first):
  File "/home/zhuyifei1999/guppy3/guppy/heapy/Classifiers.py", line 620, in owners
    self.mod.hv.update_dictowners(drg)
  File "/home/zhuyifei1999/guppy3/guppy/heapy/Classifiers.py", line 717, in owners
    return self.d.owners(X)
  File "/home/zhuyifei1999/guppy3/guppy/heapy/UniSet.py", line 1692, in get_owners
    return self.mod.Use.Clodo.classifier.owners(a)
  File "/home/zhuyifei1999/guppy3/guppy/heapy/UniSet.py", line 521, in <lambda>
    owners = property(lambda self: self.fam.get_owners(self), doc="""\
  <built-in method getattr of module object at remote 0x7f05681d4d10>
  File "/usr/lib/python3.7/rlcompleter.py", line 173, in attr_matches
    val = getattr(thisobject, word)
  File "/usr/lib/python3.7/rlcompleter.py", line 89, in complete
    self.matches = self.attr_matches(text)
gef➤  py-up
#11 Frame 0x559685b8fd90, for file /home/zhuyifei1999/guppy3/guppy/heapy/Classifiers.py, line 717, in owners (self=<ByClassOrDictOwner(mod=<Interface(_share=<Share(module=<module at remote 0x7f0567dead70>, parent=<Share(module=<module at remote 0x7f0567eda8f0>, parent=<Share(module=<module at remote 0x7f0568079f50>, parent=<Share(module=None, parent=<...>, name='', setable=(), chgable=(...), importedfrom={}, nowrap=(...), wrapattr=None, wrapping=0, data={'_parent': <...>, '_root': <...>, '_module': None, 'guppy': <...>, 'types': <Share(module=<module at remote 0x7f0568092110>, parent=<...>, name='types', setable=(...), chgable=(...), importedfrom={}, nowrap=(...), wrapattr=None, wrapping=0, data={'_parent': <...>, '_root': <...>, '_module': <module at remote 0x7f0568092110>, 'ModuleType': <type at remote 0x7f05692bc620>, 'CodeType': <type at remote 0x7f05692c1180>, 'FrameType': <type at remote 0x7f05692bee00>}, owners={}, ispackage=None, recursion=0, preload=(...)) at remote 0x7f0567e45ed0>, 'io': <Share(module=<...(truncated)
    return self.d.owners(X)
gef➤  
#15 Frame 0x559685a99280, for file /home/zhuyifei1999/guppy3/guppy/heapy/UniSet.py, line 1692, in get_owners (self=<IdentitySetFamily(mod=<Interface(_share=<Share(module=<module at remote 0x7f0567e700b0>, parent=<Share(module=<module at remote 0x7f0567eda8f0>, parent=<Share(module=<module at remote 0x7f0568079f50>, parent=<Share(module=None, parent=<...>, name='', setable=(), chgable=(...), importedfrom={}, nowrap=(...), wrapattr=None, wrapping=0, data={'_parent': <...>, '_root': <...>, '_module': None, 'guppy': <...>, 'types': <Share(module=<module at remote 0x7f0568092110>, parent=<...>, name='types', setable=(...), chgable=(...), importedfrom={}, nowrap=(...), wrapattr=None, wrapping=0, data={'_parent': <...>, '_root': <...>, '_module': <module at remote 0x7f0568092110>, 'ModuleType': <type at remote 0x7f05692bc620>, 'CodeType': <type at remote 0x7f05692c1180>, 'FrameType': <type at remote 0x7f05692bee00>}, owners={}, ispackage=None, recursion=0, preload=(...)) at remote 0x7f0567e45ed0>, 'io': <Share(module=<m...(truncated)
    return self.mod.Use.Clodo.classifier.owners(a)
gef➤  
#19 Frame 0x559685b90bb0, for file /home/zhuyifei1999/guppy3/guppy/heapy/UniSet.py, line 521, in <lambda> (self=<IdentitySetMulti at remote 0x7f0567ee4230>)
    owners = property(lambda self: self.fam.get_owners(self), doc="""\
gef➤  
#29 <built-in method getattr of module object at remote 0x7f05681d4d10>
gef➤  
#31 Frame 0x559685d6e970, for file /usr/lib/python3.7/rlcompleter.py, line 173, in attr_matches (self=<Completer(use_main_ns=1, namespace={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <type at remote 0x5596859dbe50>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7f05681d4d10>, 'hp': <_GLUECLAMP_(_share=<Share(module=<module at remote 0x7f0567edaad0>, parent=<Share(module=<module at remote 0x7f0567eda8f0>, parent=<Share(module=<module at remote 0x7f0568079f50>, parent=<Share(module=None, parent=<...>, name='', setable=(), chgable=(...), importedfrom={}, nowrap=(...), wrapattr=None, wrapping=0, data={'_parent': <...>, '_root': <...>, '_module': None, 'guppy': <...>, 'types': <Share(module=<module at remote 0x7f0568092110>, parent=<...>, name='types', setable=(...), chgable=(...), importedfrom={}, nowrap=(...), wrapattr=None, wrapping=0, data={'_parent': <...>, '_root': <...>, '_module': <module at remote 0x7f0568092110>, 'ModuleType': <type at remote 0x7...(truncated)
    val = getattr(thisobject, word)
gef➤  py-print thisobject
local 'thisobject' = <IdentitySetMulti at remote 0x7f0567ee4230>
gef➤  py-print word
local 'word' = 'owners'
gef➤  py-print words
local 'words' = {'__doc__', '__new__', '_doc_nodes', 'owners', '__reduce__', '__getattr__', '__or__', '__subclasshook__', '__dir__', '__bool__', '__xor__', '__str__', '__delattr__', '__mul__', '__getattribute__', '__len__', 'pathsout', '__ge__', '__eq__', '__rand__', '__rxor__', '_partition', 'size', '__call__', 'fam', '__le__', '__and__', '_help_url_', 'test_contains', 'referrers', 'er', '__lshift__', '__hash__', '__sub__', '__class__', '__iter__', '_hiding_tag_', '__module__', 'more', '_instahelp_', 'bysize', '__contains__', '__format__', '_er', '__sizeof__', 'get_examples', 'biper', 'get_rp', 'byid', '__lt__', 'bytype', 'by', 'brief', 'byunity', 'parts', 'stat', '_origin_', 'nodes', 'partition', 'disjoint', 'doc', '_get_help', 'byclodo', '__gt__', '__repr__', '_derive_origin_', 'dump', 'kind', 'rp', 'dictof', '__rsub__', '__getitem__', 'get_render', 'shpaths', 'count', 'sp', 'indisize', '__setattr__', '__slots__', 'maprox', 'get_shpaths', 'referents', 'byrcs', 'byidset', 'get_ckc', '__init_subclass__', '__ne__', 'pathsin'...(truncated)
gef➤  py-list
 168                for word in words:
 169                    if (word[:n] == attr and
 170                        not (noprefix and word[:n+1] == noprefix)):
 171                        match = "%s.%s" % (expr, word)
 172                        try:
>173                            val = getattr(thisobject, word)
 174                        except Exception:
 175                            pass  # Include even if attribute not set
 176                        else:
 177                            match = self._callable_postfix(val, match)
 178                        matches.append(match)

This is https://github.com/python/cpython/blob/77abf23c67c1a465a8899666c69f6bcd6930e003/Lib/rlcompleter.py#L173, it wants to know whether each of out attributes are callable.

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

No branches or pull requests

1 participant