-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
MAINT: Endorse SPECs #11780
Comments
Great idea! SPEC0 seems doable without much effort (in fact, if we drop support as per this spec, we will actually have less maintenance effort). I also like lazy loading, which we do anyway. For me, adding an additional dependency is worth the benefit of a 4x speedup. Although I'm not sure what the high adoption cost you're referring to means. |
Hence my question to @agramfort about whether a vendored (BSD-compatible of course) dependency is a workaround. It seems like it should be since we take/adapt BSD-compatible code all the time in releases... |
Yes, this is on my radar. FYI the idea behind endorsing SPECs is (IIRC) something like "numpy endorses SPEC0 and their implementation of it is described in NEP29". That particular example gets the chronology backwards (NEP29 came before SPEC0) but the idea is that projects can endorse-and-still-deviate if they have good reason to do so, and they should document on their own sites their endorsement/implementation and any deviations. For example, we might deviate if we needed to retain support for an older Python because, e.g., Freesurfer needed it or something. cc @stefanv and @tupui in case I got any of the details wrong here |
You got that perfectly 😃 Happy to read that 🚀 |
@larsoner are you talking about |
I linked to a thread where the discussion was originally about nibabel, but it's generally applicable to adding any new dependency, including the
I think in the end it might actually make it less complicated. Basically I think we can change our
I'd expect point (3) to improve/simplify our code/contribution/maintenance requirements more than the |
I agree, but pure-Python lightweight packages with zero dependencies like Re using |
@CBNR Just weighing in here as lazy_loader author: I think it's perfectly fine to use built in mechanisms (like we did for SciPy). The advantage of lazy_loader is that you can define imports as pyi files (so that code type completion still works in editors, which it won't otherwise). We have an environment variable for disabling lazy loading that's useful in testing. And we have informative deferred import errors. But, none of that is needed; we're just trying to make it easy for libraries to switch to a lazy import strategy, since we think it's a good idea :) In particular: faster imports for users, and the ability to expose submodules without cost so that libraries can be explored interactively in, e.g. IPython. Whatever route you choose, I'd be happy to review the changes for common gotchas! |
I don't think that was the consensus/conclusion we came to in #11565 EDIT: #11564. I'll ask @agramfort about vendoring over there as well, so let's move discussion about adding additional dependencies there.
Indeed to me the standardization is nice. Similar to how everyone could have used |
no strong feeling on my end. is it likely that numpy / scipy / matplotlib adopt lazy_loader so we can just rely on the same set of dependencies ? |
SciPy being SciPy, don't really count on it I am afraid 😅 we have a tendency to want to do our own magic 🪄 |
@larsoner I had forgotten that only "core" projects can endorse SPECs, but I've opened scientific-python/specs#271 to add us to the list of "adopters" of SPEC001 (lazy loading). Depending on how they respond to that one I'll look deeper into what we should do re: SPEC000 and 004 |
Okay I think that's probably good enough to close the issue at our end for now, then! |
Just to emphasize one point from above: unless lazy loading happens in https://scientific-python.org/specs/spec-0001/#type-checkers |
cc @drammock there is https://scientific-python.org/specs/ , I assume you have thoughts/ideas/knowledge from the conference but wanted to get it on our radar.
The interesting one is that might deserve some discussion is SPEC1 lazy loading. The
lazy_load
package idea seems great. We could maybe get rid of all of our nested imports except maybematplotlib
, and still have the nested import test pass. Andimport mne
would be faster because@verbose
creating functions does have a non-zero overhead, which I think accounts for most of this:But this would be another package to add to MNE-Python's dependency list (which has a high adoption cost as discussed before) or we'd have to vendor it, which would make the conda-forge people unhappy. Or we'd have to do some hybrid where we
try: import lazy_loader; except Exception: <import our vendored one>
.@agramfort would vendoring a BSD module be problematic from the industry-adoption end?
The text was updated successfully, but these errors were encountered: