You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
libgap: do not restrict libgap.<tab> completion to a fixed list #27923
Since #19917, tab completion on libgap returns a fixed list. As noted there, new global functions and objects introduced when loading packages remain therefore hidden. Now that loading packages in libgap is much better supported, this is really becoming an issue.
Proposal, after discussion with GAP devs: use the same implementation as in the plain gap interface (namely ask GAP for the list of global names), without a cache.
Pros:
Principle of less surprise: keep plain GAP, Sage's gap and Sage's libgap consistent;
Follow the design decisions of GAP to take advantage of their expertise;
Supports loading packages and advertising their content (this support was postponed to a later ticket in Libgap tab completion #19917);
No need any more to maintain in Sage a list of "important" GAP functions.
With libgap, fetching the list of global GAP symbols is quasi instantaneous:
sage: %time a = [str(x) for x in libgap.NamesSystemGVars()]
CPU times: user 21.2 ms, sys: 0 ns, total: 21.2 ms
Wall time: 20.9 ms
Hence the implementation is simple; we need not worry about caching, invalidating the cache upon loading packages, ...
What I'd like to understand whether with this approach there is a performance hit if one
uses libgap.Blah calls in a loop.
Calling (lib)GAP inside a loop to determine the function to call would quickly become very slow.
changed the title [-]libgap: do not restrict libgab.<tab> completion to a fixed list[/-][+]libgap: do not restrict libgap.<tab> completion to a fixed list[/+]on Jun 4, 2019
What I'd like to understand whether with this approach there is a performance hit if one
uses libgap.Blah calls in a loop.
Calling (lib)GAP inside a loop to determine the function to call would quickly become very slow.
This ticket is only about tab completion (VIA dir(self)), and is orthogonal to attribute access (via __getattr__). So this should have no influence whatsoever on libgap.Blah calls.
#27911 is about attribute access libgap.xxx whenever xxx exists in GAP. This one is about what should appear in the tab-completion on libgap. Of course some level of consistency is good, but other than this they are independent issues.
I see, yes that's a subtle difference. In practice there's a lot of overlap in terms of the implementation details.
I've never quite understood the current implementation that uses (and limits one to) a hard-coded list. I remember asking about this on sage-devel a while ago when I was first dealing with it, and nobody had a very concrete answer, including Volker who I think wrote it (not sure though).
Would definitely give +1 to a better solution if there is one.
Just repeating my comment from #27911, this tends to cough up a lot of private / undocumented functions in GAP that necessarily are in the public GAP namespace but users aren't supposed to access.
The current implementation uses IsDocumentedWord to only return documented symbols. Which also is slow as molasses since it grinds through the documentation, so it needs to be cached.
On the plus side, gap itself tab-completes over everything so at least we'd match that bug/misfeature/feature (pick your choice). So I'm fine with changing it...
I agree with Volker that it's a shame that GAP's global namespace is so overloaded, but that's a (mis)feature of GAP that it doesn't ultimately help us to fight against.
Perhaps as a policy, when using GAP code internally in Sage only those functions for which IsDocumentedWord is true should be used. Not sure if there's a great way to enforce that except by checking manually.
I agree with Volker that it's a shame that GAP's global namespace is so overloaded, but that's a (mis)feature of GAP that it doesn't ultimately help us to fight against.
Ok! I'll proceed then. Thanks for feedback.
Perhaps as a policy, when using GAP code internally in Sage only those functions for which IsDocumentedWord is true should be used. Not sure if there's a great way to enforce that except by checking manually.
As the Sage-8.8 release milestone is pending, we should delete the sage-8.8 milestone for tickets that are not actively being worked on or that still require significant work to move forward. If you feel that this ticket should be included in the next Sage release at the soonest please set its milestone to the next release milestone (sage-8.9).
Activity
nthiery commentedon Jun 3, 2019
If we agree that this is the way to go, I can take care of the implementation.
dimpase commentedon Jun 4, 2019
What I'd like to understand whether with this approach there is a performance hit if one
uses
libgap.Blahcalls in a loop.Calling (lib)GAP inside a loop to determine the function to call would quickly become very slow.
[-]libgap: do not restrict libgab.<tab> completion to a fixed list[/-][+]libgap: do not restrict libgap.<tab> completion to a fixed list[/+]nthiery commentedon Jun 4, 2019
Hi Dima,
This ticket is only about tab completion (VIA
dir(self)), and is orthogonal to attribute access (via__getattr__). So this should have no influence whatsoever onlibgap.Blahcalls.embray commentedon Jun 7, 2019
What is the relationship between this ticket, and #27911 which is older?
dimpase commentedon Jun 7, 2019
their exact relationship status is "legally separated" :-)
nthiery commentedon Jun 7, 2019
:-)
#27911 is about attribute access
libgap.xxxwhenever xxx exists in GAP. This one is about what should appear in the tab-completion on libgap. Of course some level of consistency is good, but other than this they are independent issues.embray commentedon Jun 7, 2019
I see, yes that's a subtle difference. In practice there's a lot of overlap in terms of the implementation details.
I've never quite understood the current implementation that uses (and limits one to) a hard-coded list. I remember asking about this on sage-devel a while ago when I was first dealing with it, and nobody had a very concrete answer, including Volker who I think wrote it (not sure though).
Would definitely give +1 to a better solution if there is one.
vbraun commentedon Jun 10, 2019
Just repeating my comment from #27911, this tends to cough up a lot of private / undocumented functions in GAP that necessarily are in the public GAP namespace but users aren't supposed to access.
The current implementation uses IsDocumentedWord to only return documented symbols. Which also is slow as molasses since it grinds through the documentation, so it needs to be cached.
On the plus side, gap itself tab-completes over everything so at least we'd match that bug/misfeature/feature (pick your choice). So I'm fine with changing it...
nthiery commentedon Jun 10, 2019
Thanks Volker for the feedback!
Agreed, displaying private functions is on the misfeature side. Hopefully that will eventually get fixed on the GAP side.
If no one objects I'll make libgap's completion consistent with GAP's later this week or during Cernay.
embray commentedon Jun 11, 2019
I agree with Volker that it's a shame that GAP's global namespace is so overloaded, but that's a (mis)feature of GAP that it doesn't ultimately help us to fight against.
Perhaps as a policy, when using GAP code internally in Sage only those functions for which
IsDocumentedWordis true should be used. Not sure if there's a great way to enforce that except by checking manually.nthiery commentedon Jun 11, 2019
Replying to @embray:
Ok! I'll proceed then. Thanks for feedback.
+1
embray commentedon Jun 14, 2019
As the Sage-8.8 release milestone is pending, we should delete the sage-8.8 milestone for tickets that are not actively being worked on or that still require significant work to move forward. If you feel that this ticket should be included in the next Sage release at the soonest please set its milestone to the next release milestone (sage-8.9).
embray commentedon Feb 16, 2021
Changed keywords from none to gap libgap
dimpase commentedon Mar 25, 2021
Anything on this in view of gappy ?
embray commentedon Mar 29, 2021
It's been on my todo list but I didn't make an explicit issue for it; thanks for reminding me: embray/gappy#15