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

Lazy initialization of libgap #27678

Closed
embray opened this issue Apr 16, 2019 · 2 comments
Closed

Lazy initialization of libgap #27678

embray opened this issue Apr 16, 2019 · 2 comments

Comments

@embray
Copy link
Contributor

embray commented Apr 16, 2019

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.

Component: interfaces

Author: Erik Bray

Branch/Commit: u/embray/libgap/lazy-initialization @ a756429

Issue created by migration from https://trac.sagemath.org/ticket/27678

@embray embray added this to the sage-8.8 milestone Apr 16, 2019
@embray

This comment has been minimized.

@embray
Copy link
Contributor Author

embray commented Apr 16, 2019

comment:2

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

@embray embray closed this as completed Apr 16, 2019
@embray embray removed this from the sage-8.8 milestone Apr 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant