[SciPy-User] Bottleneck 0.4.1

Keith Goodman kwgoodman@gmail....
Sun Mar 13 16:32:39 CDT 2011


On Tue, Mar 8, 2011 at 6:06 PM, Wes McKinney <wesmckinn@gmail.com> wrote:

> One random question. Any idea on the long import time:
>
> $ time python -c "import bottleneck"
>
> real    0m0.712s
> user    0m0.546s
> sys     0m0.114s
> $ time python -c "import numpy"
>
> real    0m0.142s
> user    0m0.090s
> sys     0m0.049s
> $ time python -c "import scipy"
>
> real    0m0.201s
> user    0m0.132s
> sys     0m0.066s

Bottleneck imports are now 3x faster. I switched to a lazy import of
scipy (Bottleneck rarely uses scipy).

Before:

$ time python -c "import bottleneck"
real	0m0.196s
user	0m0.150s
sys	0m0.040s

After:

$ time python -c "import bottleneck"
real	0m0.061s
user	0m0.010s
sys	0m0.050s

Does adding Bottleneck to your package increase the import time by
0.06 seconds? No, not if your package imports numpy:

$ time python -c "import numpy; import bottleneck"
real	0m0.060s
user	0m0.020s
sys	0m0.030s

I used this pattern for lazy imports:

email = None
def parse_email():
    global email
    if email is None:
        import email

which I found here:
http://wiki.python.org/moin/PythonSpeed/PerformanceTips#Import_Statement_Overhead

Thanks, Wes, for the report.


More information about the SciPy-User mailing list