[Numpy-discussion] Lazy imports again

Charles R Harris charlesr.harris@gmail....
Tue Jul 17 07:13:13 CDT 2012


On Tue, Jul 17, 2012 at 1:31 AM, David Cournapeau <cournape@gmail.com>wrote:

> On Mon, Jul 16, 2012 at 5:28 PM, Charles R Harris
> <charlesr.harris@gmail.com> wrote:
> > Hi All,
> >
> > Working lazy imports would be useful to have. Ralf is opposed to the idea
> > because it caused all sorts of problems on different platforms when it
> was
> > tried in scipy. I thought I'd open the topic for discussion so that folks
> > who had various problems/solutions could offer input and the common
> > experience could be collected in one place. Perhaps there is a solution
> that
> > actually works.
>
> I have never seen a lazy import system that did not cause issues in
> one way or the other. Lazy imports make a lot of sense for an
> application (e.g. mercurial), but I think it is a mistake to solve
> this at the numpy level.
>
> This should be solved at the application level, and there are
> solutions for that. For example, using the demandimport code from
> mercurial (GPL) cuts down the numpy import time by 3 on my mac if one
> uses np.zeros (100ms -> 50 ms, of which 25 are taken by python
> itself):
>
> """
> import demandimport
> demandimport.enable()
>
> import numpy as np
>
> a = np.zeros(10)
> """
>
> To help people who need fast numpy imports, I would suggest the
> following course of actions:
>    - start benchmarking numpy import in a per-commit manner to detect
> significant regressions (like what happens with polynomial code)
>    - have a small FAQ on it, with suggestion for people who need to
> optimize their short-lived script
>
>
That's really interesting. I'd like to see some folks try that solution.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120717/e5e83556/attachment.html 


More information about the NumPy-Discussion mailing list