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

Various fixes to lazy imports #22755

Closed
jdemeyer opened this issue Apr 4, 2017 · 28 comments
Closed

Various fixes to lazy imports #22755

jdemeyer opened this issue Apr 4, 2017 · 28 comments

Comments

@jdemeyer
Copy link

jdemeyer commented Apr 4, 2017

Assorted fixes to lazy imports:

  1. Drop support for lazy_import(overwrite=False) which was used only in one place in a dubious way to implement a 2-level lazy import (a lazy import being lazily imported).

  2. More optimal code for binary operations like __add__ by avoiding the operator module.

  3. Move the code to replace a lazy import in a class namespace from _get_object() to __get__.

  4. Partially inline _get_object() with a new cdef inline function for the case that the object has been initialized.

  5. A lazy import without at_startup being imported at startup is now an error (it used to just print a message, which is less useful than an error traceback).

  6. Implement matmul (pointless in Python 2, but useful for Python 3).

  7. Clean up the function lazy_import a bit.

Component: misc

Author: Jeroen Demeyer

Branch/Commit: 4dda1ae

Reviewer: Vincent Delecroix

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

@jdemeyer jdemeyer added this to the sage-8.0 milestone Apr 4, 2017
@jdemeyer
Copy link
Author

jdemeyer commented Apr 4, 2017

Branch: u/jdemeyer/ticket/22755

@jdemeyer
Copy link
Author

jdemeyer commented Apr 4, 2017

Commit: d2bb491

@jdemeyer
Copy link
Author

jdemeyer commented Apr 4, 2017

New commits:

94302caDo not declare functions/methods as "cdef inline"
9e5715eVarious improvements to lazy imports
d2bb491Whitespace fix

@jdemeyer

This comment has been minimized.

@jdemeyer

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 5, 2017

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

8aac18aVarious improvements to lazy imports

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 5, 2017

Changed commit from d2bb491 to 8aac18a

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 5, 2017

Changed commit from 8aac18a to f3ede00

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 5, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

f3ede00Use exact type check in obj()

@jdemeyer
Copy link
Author

jdemeyer commented Apr 9, 2017

Changed dependencies from #22753 to none

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 10, 2017

Changed commit from f3ede00 to 7bf2ce8

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 10, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

7bf2ce8Partially inline LazyImport._get_object()

@jdemeyer

This comment has been minimized.

@videlec
Copy link
Contributor

videlec commented May 19, 2017

comment:10

You expect the following traceback to be accepted by doctests?

Traceback (most recent call last):
  File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 498, in _run
    self.compile_and_execute(example, compiler, test.globs)
  File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 861, in compile_and_execute
    exec(compiled, globs)
  File "<doctest sage.misc.lazy_import.test_fake_startup[3]>", line 1, in <module>
    my_ZZ(Integer(123))
  File "sage/misc/lazy_import.pyx", line 346, in sage.misc.lazy_import.LazyImport.__call__ (build/cythonized/sage/misc/lazy_import.c:3495)
    return self._get_object()(*args, **kwds)
  File "sage/misc/lazy_import.pyx", line 210, in sage.misc.lazy_import.LazyImport._get_object (build/cythonized/sage/misc/lazy_import.c:2139)
    raise RuntimeError(f"resolving lazy import {self._name} during startup")
RuntimeError: resolving lazy import ZZ during startup

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 19, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

4dda1aeFix traceback

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 19, 2017

Changed commit from 7bf2ce8 to 4dda1ae

@jdemeyer
Copy link
Author

comment:12

Replying to @videlec:

You expect the following traceback to be accepted by doctests?

Apparently yes (see patchbot) :-)

Anyway, I fixed it.

@videlec
Copy link
Contributor

videlec commented May 23, 2017

comment:13

Weird patchbot failure on quasar! Do you think it is related to your ticket?

@jdemeyer
Copy link
Author

comment:14

Replying to @videlec:

Weird patchbot failure on quasar! Do you think it is related to your ticket?

Almost certainly not.

@videlec
Copy link
Contributor

videlec commented May 24, 2017

comment:15

Replying to @jdemeyer:

Replying to @videlec:

Weird patchbot failure on quasar! Do you think it is related to your ticket?

Almost certainly not.

Note that all tests pass on some other tickets. I will relaunch it.

@jdemeyer
Copy link
Author

jdemeyer commented Jun 2, 2017

comment:16

The most recent patchbot run passes all tests.

@videlec
Copy link
Contributor

videlec commented Jun 3, 2017

comment:17

The documentation of the overwrite argument in lazy_import disappeard.

NOTE: though it is deprecated

@videlec
Copy link
Contributor

videlec commented Jun 3, 2017

comment:18

Why stuff from sage.dynamics.interval_exchanges and sage.dynamics.flat_surfaces not lazily imported anymore?

@jdemeyer
Copy link
Author

jdemeyer commented Jun 3, 2017

comment:19

As I tried to explain in the ticket description, it was lazily importing a lazy import.

@jdemeyer
Copy link
Author

comment:20

Ping?

@videlec
Copy link
Contributor

videlec commented Jun 20, 2017

Reviewer: Vincent Delecroix

@videlec
Copy link
Contributor

videlec commented Jun 20, 2017

comment:22

done!

@vbraun
Copy link
Member

vbraun commented Jun 22, 2017

Changed branch from u/jdemeyer/ticket/22755 to 4dda1ae

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