patches to reduce import costs

I don't see a place to submit patches. Is there a patch manager for numpy? Here's a patch to defer importing 'tempfile' until needed. I previously mentioned one other place that didn't need tempfile. With this there is no 'import tempfile' during 'import numpy' This improves startup by about 7% --- numpy/lib/_datasource.py (revision 5576) +++ numpy/lib/_datasource.py (working copy) @@ -35,7 +35,6 @@ __docformat__ = "restructuredtext en" import os -import tempfile from shutil import rmtree from urlparse import urlparse @@ -131,6 +130,7 @@ self._destpath = os.path.abspath(destpath) self._istmpdest = False else: + import tempfile self._destpath = tempfile.mkdtemp() self._istmpdest = True Andrew dalke@dalkescientific.com

On Thu, Jul 31, 2008 at 15:44, Andrew Dalke <dalke@dalkescientific.com> wrote:
I don't see a place to submit patches. Is there a patch manager for numpy?
http://projects.scipy.org/scipy/numpy -- 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

On Fri, Aug 1, 2008 at 5:44 AM, Andrew Dalke <dalke@dalkescientific.com> wrote:
I don't see a place to submit patches. Is there a patch manager for numpy?
Attaching a patch to numpy trac is the way to go: http://projects.scipy.org/scipy/numpy thanks for the patch, David

For the help of freeze packages, it would be great if you could add a file that lists all of the deferred imports that you run across. That way, we can add/update recipes more easily for py2app, py2exe, bbfreeze, etc. Thanks, -Kevin On Thu, Jul 31, 2008 at 4:44 PM, Andrew Dalke <dalke@dalkescientific.com>wrote:
I don't see a place to submit patches. Is there a patch manager for numpy?
Here's a patch to defer importing 'tempfile' until needed. I previously mentioned one other place that didn't need tempfile. With this there is no 'import tempfile' during 'import numpy'
This improves startup by about 7%
--- numpy/lib/_datasource.py (revision 5576) +++ numpy/lib/_datasource.py (working copy) @@ -35,7 +35,6 @@ __docformat__ = "restructuredtext en"
import os -import tempfile from shutil import rmtree from urlparse import urlparse
@@ -131,6 +130,7 @@ self._destpath = os.path.abspath(destpath) self._istmpdest = False else: + import tempfile self._destpath = tempfile.mkdtemp() self._istmpdest = True
Andrew dalke@dalkescientific.com
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Kevin, Do you mean add a file on the Wiki or in the source tree somewhere? Chris On Thu, Jul 31, 2008 at 2:14 PM, Kevin Jacobs <jacobs@bioinformed.com> <bioinformed@gmail.com> wrote:
For the help of freeze packages, it would be great if you could add a file that lists all of the deferred imports that you run across. That way, we can add/update recipes more easily for py2app, py2exe, bbfreeze, etc.
Thanks, -Kevin

On Thu, Jul 31, 2008 at 7:08 PM, Christopher Burns <cburns@berkeley.edu>wrote:
Do you mean add a file on the Wiki or in the source tree somewhere?
Either or both-- so long as there is a convenient place to find them. I suppose a Wiki page would be most flexible, since it could be expanded to discuss deeper packaging issues. Thanks, -Kevin

2008/7/31 Andrew Dalke <dalke@dalkescientific.com>:
I don't see a place to submit patches. Is there a patch manager for numpy?
Here's a patch to defer importing 'tempfile' until needed. I previously mentioned one other place that didn't need tempfile. With this there is no 'import tempfile' during 'import numpy'
This improves startup by about 7%
Thanks for the patch. Applied in r5588. Cheers Stéfan
participants (6)
-
Andrew Dalke
-
Christopher Burns
-
David Cournapeau
-
Kevin Jacobs <jacobs@bioinformed.com>
-
Robert Kern
-
Stéfan van der Walt