[SciPy-user] NumPy vs. SciPy and other speed comparisons

Robert Kern robert.kern@gmail....
Wed Jun 11 05:44:34 CDT 2008

On Wed, Jun 11, 2008 at 05:33, Robert Kern <robert.kern@gmail.com> wrote:
> On Wed, Jun 11, 2008 at 05:06, Pearu Peterson <pearu@cens.ioc.ee> wrote:

>> We used to have postponed import hooks for that in past
>> but afaik we dropped these because they were hackish and at some moment
>> the time of importing scipy improved (I think it was in Python 2.4 or
>> 2.5) considerably.
> The problem is that we left scipy.pkgload in, and creating that from
> numpy._import_tools.PackageLoader implicitly adds all of the
> subpackages to scipy.__all__.

Correction: we actually do call pkgload(postpone=True). However, even
with the postponed import (which does not add any proxy objects), it
still appends to __all__. I believe the following patch to numpy fixes
the problem, but I'm not sure if leaving the if clause alone is
correct in all cases:

Index: numpy/_import_tools.py
--- numpy/_import_tools.py      (revision 5245)
+++ numpy/_import_tools.py      (working copy)
@@ -183,9 +183,6 @@
             postpone_import = getattr(info_module,'postpone_import',False)
             if (postpone and not global_symbols) \
                    or (postpone_import and postpone is not None):
-                self.log('__all__.append(%r)' % (package_name))
-                if '.' not in package_name:
-                    self.parent_export_names.append(package_name)

             old_object = frame.f_locals.get(package_name,None)

This can probably go into numpy 1.1.1 as a bugfix, so I don't think
it's critical to work around it in scipy/__init__.py.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco

More information about the SciPy-user mailing list