Re: Idiomatic import for SciPy

Ross Barnowski <[email protected]> Tue, 23 May 2023 11:43:15 -0700
Newsgroups gmane.comp.python.scientific.devel
Message-ID <CADyYXurPY+2vBSo74xsaVw-mO8HhJ_ZpyekcSG6nip94vJog6w@mail.gmail.com>
Thanks Pamphile.

I just wanted to chime in and note that the introduction of lazy loading
has (IMO) been a huge usability improvement. I personally now use `import
scipy as sp` in code that I write and libraries that I contribute to like
networkx have also adopted this pattern. The main reason that NetworkX has
adopted this pattern is to ensure consistency and explicitness in the code
base. For example, in networkx we have references to at least 4 different
`linalg` packages: `numpy.linalg`, `scipy.linalg`, `scipy.sparse.linalg`
and `networkx.linalg`. We now always refer to these explicitly from the
top-level package alias, i.e. `np.linalg`, `sp.linalg`, `sp.sparse.linalg`
etc.

This is of course only one of many possible access patterns, but the
introduction of lazy loading made this much more convenient!

~Ross

On Tue, May 23, 2023 at 10:40 AM Pamphile Roy <[email protected]>
wrote:

> Hi everyone,
>
> Since SciPy 1.9, we now have a lazy import mechanism which allows us to do
> `import scipy` and then work on any submodules without waiting time due to
> the import itself.
>
> NumPy and Pandas, just to name these, have set a precedence for an
> idiomatic way of importing their library. This is arguably an advantage for
> introspection, debugging, teaching, consistency or even communication
> purposes. Hence, I would like to propose that we also adopt an idiomatic
> import style for SciPy.
>
> If we would want to move forward with that idea, I would propose to make a
> brainstorming session with interested people to discuss the topic. This
> could for instance be a topic for next week’s community call.
>
> Cheers,
> Pamphile
>
>
> _______________________________________________
> SciPy-Dev mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/scipy-dev.python.org/
> Member address: [email protected]
>

_______________________________________________
SciPy-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/scipy-dev.python.org/
Member address: [email protected]