#27678 closed enhancement (duplicate)

Lazy initialization of libgap

Reported by: embray Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: interfaces Keywords:
Cc: Merged in:
Authors: Erik Bray Reviewers:
Report Upstream: N/A Work issues:
Branch: u/embray/libgap/lazy-initialization (Commits) Commit: a756429e85c1485d697d1cfc76605289b30e5896
Dependencies: Stopgaps:

Description (last modified by embray)

Previously the Gap class that implements the (effectively singleton) libgap instance variable in sage.libs.gap.libgap called initialize() (the function which initializes libgap for the process) in its __init__ method.

Because of this, it was impossible to import it without causing libgap to be initialized, creating slowdown during Sage initialization. The tradeoff is that most code in Sage that uses the libgap interface has to awkwardly use inline imports of from sage.libs.gap.libgap import libgap all over the place.

I would like to do away with that, especially for work on #18267

This removes initialize() from Gap.__init__() and instead carefully places calls to initialize() just in the few places where it's absolutely crucial to ensure libgap is initialized first (specifically in code paths that users and developers are actually intended to use directly; it is not added directly to every single function that uses GAP objects).

This sacrifices some simplicity in implementation of the libgap interface for simplicity in using it, which I think is crucial for updating more code in Sage to use it over the pexpect interface.

Note: I originally posted this as MR11 on GitLab, but it did not synchronize due probably to an apparent system-wide problem with webhooks being triggered on gitlib.org. I will keep the merge request open for now until this ticket is closed.

Change History (2)

comment:1 Changed 14 months ago by embray

  • Description modified (diff)
  • Status changed from new to needs_review

comment:2 Changed 14 months ago by embray

  • Milestone changed from sage-8.8 to sage-duplicate/invalid/wontfix
  • Resolution set to duplicate
  • Status changed from needs_review to closed

Closing this one since the merge request hook just finally kicked off apparently: #27680

Note: See TracTickets for help on using tickets.