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

MR11: Lazy initialization of libgap #27680

Closed
sagetrac-gitlab-bot mannequin opened this issue Apr 16, 2019 · 8 comments
Closed

MR11: Lazy initialization of libgap #27680

sagetrac-gitlab-bot mannequin opened this issue Apr 16, 2019 · 8 comments

Comments

@sagetrac-gitlab-bot
Copy link
Mannequin

sagetrac-gitlab-bot mannequin commented Apr 16, 2019

E. Madison Bray (@embray) opened a merge request at https://gitlab.com/sagemath/sage/merge_requests/11:


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](https://github.com/sagemath/sage-prod/issues/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.

Component: interfaces

Author: Erik Bray

Branch/Commit: e687ee6

Reviewer: Dima Pasechnik

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

@sagetrac-gitlab-bot sagetrac-gitlab-bot mannequin added this to the sage-8.8 milestone Apr 16, 2019
@embray

This comment has been minimized.

@sagetrac-gitlab-bot
Copy link
Mannequin Author

sagetrac-gitlab-bot mannequin commented Apr 17, 2019

comment:2

New commits added to merge request. I updated the commit SHA-1. This was a forced push. New commits:

de4332bChange libgap initialization to work lazily. Don't initialize() in Gap.__init__ but only just before libgap actually needs to be initialized.
e687ee6This test no longer makes sense in light of lazy initialization of libgap

@sagetrac-gitlab-bot
Copy link
Mannequin Author

sagetrac-gitlab-bot mannequin commented Apr 17, 2019

Changed commit from a756429 to e687ee6

@embray
Copy link
Contributor

embray commented Apr 17, 2019

Changed author from E. Madison Bray to Erik Bray

@embray
Copy link
Contributor

embray commented Apr 17, 2019

comment:3

Apparently my gitlab display name is not the same as my canonical name in Sage's build stuff. Perhaps we could add both.

@dimpase
Copy link
Member

dimpase commented May 8, 2019

Reviewer: Dima Pasechnik

@dimpase
Copy link
Member

dimpase commented May 8, 2019

comment:4

looks good. send it to the bots.

@vbraun
Copy link
Member

vbraun commented May 12, 2019

Changed branch from u/galois/mrs/11/u/embray/libgap/lazy-initialization to e687ee6

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

3 participants