Closed spyder-bot closed 9 years ago
From ccordoba12 on 2011-11-27T20:06:35Z
Labels: Cat-CodeCompletion
From ccordoba12 on 2013-02-13T09:39:30Z
Blocking: spyderlib:1272
From ccordoba12 on 2013-02-13T11:34:49Z
Labels: MS-v2.2
From ccordoba12 on 2013-02-22T08:14:37Z
This issue was updated by revision 985cd5d48d95 .
Status: Fixed
From ccordoba12 on 2011-11-27T22:39:39Z
While working with scipy.stats, I noticed that code completion for it was very slow the first time it was called. After reading your discussion with Ali about the numpy completion slowness, I decided to add it to 'extension_modules'.
Things worked great (time was reduced from about 6 seconds to milliseconds) but then I couldn't get completions for the distribution methods (cdf, pmf, entropy, etc). So I turned on DEBUG on sourcecode/codeeditor and got this traceback while trying to get the completion of scipy.stats.binom:
Traceback (most recent call last): File "/home/carlos/Projects/spyder/trunk/spyderlib/widgets/sourcecode/codeeditor.py", line 135, in get_completion_list source_code, offset, resource) File "/home/carlos/Projects/spyder/trunk/rope/contrib/codeassist.py", line 33, in code_assist return assist() File "/home/carlos/Projects/spyder/trunk/rope/contrib/codeassist.py", line 325, in call completions = list(self._code_completions().values()) File "/home/carlos/Projects/spyder/trunk/rope/contrib/codeassist.py", line 404, in _code_completions result.update(self._dotted_completions(module_scope, inner_scope)) File "/home/carlos/Projects/spyder/trunk/rope/contrib/codeassist.py", line 340, in _dotted_completions for name, pyname in element.get_attributes().items(): File "/home/carlos/Projects/spyder/trunk/rope/base/utils.py", line 10, in _wrapper setattr(self, name, func(self, _args, *_kwds)) File "/home/carlos/Projects/spyder/trunk/rope/base/builtins.py", line 115, in get_attributes return _object_attributes(self.builtin, self) File "/home/carlos/Projects/spyder/trunk/rope/base/builtins.py", line 128, in _object_attributes pyobject = BuiltinFunction(builtin=child, parent=parent) File "/home/carlos/Projects/spyder/trunk/spyderlib/rope_patch.py", line 99, in init self.argnames = getargs(self.builtin) File "/home/carlos/Projects/spyder/trunk/spyderlib/utils/dochelpers.py", line 134, in getargs args = getargsfromdoc(func_obj) File "/home/carlos/Projects/spyder/trunk/spyderlib/utils/dochelpers.py", line 119, in getargsfromdoc return getargsfromtext(obj.doc, obj.name) AttributeError: 'vectorize' object has no attribute 'name'
Then I printed the func_obj variable in utils/dochelpers/getargs and I got even more startling results while trying to do the same thing:
<function call at 0x4732398> <built-in method format of nbinom_gen object at 0x472fed0> <function init at 0x4731488> <built-in method new of type object at 0x84e6a0> <built-in method reduce of nbinom_gen object at 0x472fed0> <built-in method reduce_ex of nbinom_gen object at 0x472fed0> <built-in method sizeof of nbinom_gen object at 0x472fed0> <built-in method subclasshook of type object at 0x4803df0> <function _argcheck at 0x4732d70> <function _cdf at 0x4732ed8> <function _cdfsingle at 0x4731848> <function _construct_default_doc at 0x4731500> <function _construct_doc at 0x4731578> <function _entropy at 0x47322a8> <function _fix_loc at 0x46829b0> <function _fix_loc_scale at 0x4682938> <function _isf at 0x4731b18> <function _logcdf at 0x4731938> <function _logpmf at 0x4732e60> <function _logsf at 0x4731a28> <function _munp at 0x4731c08> <function _nonzero at 0x4731668> <function _pmf at 0x4732de8> <function _ppf at 0x4733050> <function _rvs at 0x4732cf8> <function _sf at 0x47319b0> <function _sf_skip at 0x4732f50> <function _stats at 0x47330c8> <numpy.lib.function_base.vectorize object at 0x472ff10> <function cdf at 0x4731de8> <function entropy at 0x4732320> <function expect at 0x4732410> <function freeze at 0x4732230> <numpy.lib.function_base.vectorize object at 0x472fc10>
After a couple of hours of investigation I came to the conclusion that PatchedBuiltinFunction and PatchedBuiltinName in rope_patch are the culprits for messing things up in this weird way. If I comment them then completion works as expected although (obviously) calltip generation doesn't work anymore.
I bring the issue because it seems that to get decent code completion times we will need to add a lot of modules and submodules to extension_modules.
Original issue: http://code.google.com/p/spyderlib/issues/detail?id=853