On Sun, Sep 28, 2008 at 1:06 PM, mabshoff <[EMAIL PROTECTED]> wrote:
>
> Hello folks,
>
> to optimize startup time we did move numpy imports "down" into
> individual Cython files. Unfortunately every time we do so we end up
> leaking anywhere from 700 to 900 bytes or so. Since that import can be
> in frequently visited operations I would strongly suggest we limit
> ourselves to one global numpy import in all.py.

You're suggesting that doing

   import numpy
   import numpy

would leak twice.  Or that doing import numpy in foo.py and bar.py
would both leak.  That's really weird/disturbing, and doesn't match
at all with how I think Python behaves with respect to importing a
module that has already been imported.

I'm not claiming that the leaks aren't happening, just that there is
something extra fishy going on.

> In 3.1.3 we will be
> upgrading to numpy 1.2 which import significantly faster than 1.1 and
> especially 1.0.4. Since we fix 8 byte leaks I would certainly suggest
> that we do the same for a 700+ byte leak, even if that slows down the
> startup time of Sage about 0.2s on sage.math. I noticed the numpy
> import leak all over the Sage doctests.

0.2s on sage.math can be 1s (or more) on some machines, and is
really lame.  However, numpy 1.2 may be much much better I hope;
we'll see.

It may be possible to have a lazy import in all.py, i.e., something like

def import_numpy():
    if numpy already imported do nothing
    otherwise import numpy

and then any code that would do

   import numpy
   numpy.blah

instead would call that import_numpy() function that
would be defined in some module sage.foo,
then use sage.foo.numpy.

>
> Cheers,
>
> Michael
> >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to