-
-
Notifications
You must be signed in to change notification settings - Fork 544
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_import breaks CachedRepresentation #19628
Comments
comment:1
The attached branch is the one which exhibits the error. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Changed dependencies from #19152 to none |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:9
Should we special-case |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:12
There are many subtle problems with lazy_import and some of them are fairly fundamental. The basic take-away is: don't lazy_import objects, but lazy_import functions that produce objects (
Many of our If we insert a little helper function into
then you can see from
that accessing If instead you do (and this is how NN should be imported into the toplevel if at all):
As you can see, basically even
is an erroneous use of a The reason why mathematically interesting objects themselves should probably not be lazily imported, but only their access functions is because
will always be problematic: The LazyImport object doesn't get a chance to remove itself. On the other hand, accessing the object via Of course, We could clean up scopes (but that should happen in basically all
Rather than hobbling EqualityById to accommodate for the hack that is |
comment:13
Replying to @nbruin:
Of course, now the question becomes: which scopes? If you can hand me a list of
Thanks for the pointer, I fixed this. |
This comment has been minimized.
This comment has been minimized.
comment:14
One thing which we could easily do is to change |
Changed commit from |
Changed branch from u/cheuberg/19152-arb-misc-lazy-import to none |
comment:16
Still if we agree that it can't be done safely then maybe it's a bad idea? An alternative might be to have a proxy object that, instead of trying to look like the original object, relies on the preparser to replace it? E.g. the preparser replaces |
comment:18
Replying to @vbraun:
What do the two "it"s refer to in this sentence? Fixing cached functions can be done safely. We already pre-process arguments to cached functions in Automatically "fixing" lazy imports in
I'm not convinced that we want to involve the preparser for this. What if somebody writes
you don't want this to be replaced by
|
comment:19
Replying to @jdemeyer:
All scopes that
(and then we should hope that no fancy shenanigans have happened with the bindings during module initialization) We should consider how badly this affects startup times. In time-critical bits, it may be better to use a fresh One could run this process on The namespaces registered under |
comment:28
Replying to @nbruin:
Are you thinking of |
comment:29
Replying to @jdemeyer:
That would be one hook. But there's more.
Note that the user didn't rebind ZZ and yet its identity has changed. That can affect all kinds of things. You'd basically need But perhaps your experiments end up indicating something else. |
comment:30
Replying to @nbruin:
So, what's your proposal then? Close this ticket as wontfix and change the lazy_import of
Which "experiments" do you mean? You mean with |
comment:31
Replying to @jdemeyer:
Yes. Or if NN is too expensive to import at startup, adapt the places where NN is accessed (the count above shows about 10 modules (including The other thing we should do is clean up the mess of mis-lazy_imported objects. As the list above shows, a lot of lazy_imports don't have a chance of ever clearing themselves up. The penalty of accessing an object through a lazy_import isn't that high, but the problem is these things compound. We already have lazy_imports that point to lazy_imports. I propose:
but perhaps that's better handled on a different ticket. |
Commit: |
New commits:
|
Author: Jeroen Demeyer |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
Dependencies: #23102 |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:41
I haven't read all the comments on this ticket, but the problem statement is clear and the proposed fix makes perfect sense. |
Reviewer: Erik Bray |
Changed branch from u/jdemeyer/lazy_import_breaks_cachedrepresentation to |
Changed commit from |
NN
is a lazy_import and therefore we havebut
This gives problems with
CachedRepresentation
:Depends on #23102
CC: @vbraun @jdemeyer @mezzarobba @simon-king-jena @nthiery
Component: coercion
Author: Jeroen Demeyer
Branch:
866eddd
Reviewer: Erik Bray
Issue created by migration from https://trac.sagemath.org/ticket/19628
The text was updated successfully, but these errors were encountered: