8000 It seemed that NumPy spend a lot of time on loading packages · Issue #14374 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
It seemed that NumPy spend a lot of time on loading packages #14374
Closed
@ringsaturn

Description

@ringsaturn

Reproducing code example:

Write a demo.py:

from __future__ import print_function

import time

import numpy as np
import six

if six.PY3:
    timer_func = time.process_time
else:
    timer_func = time.clock

n = 1000

start = timer_func()
precise = 2
for i in range(n):
    np.round(np.array(range(i)), precise)
end = timer_func()
print(end-start)

Then run it like this:

# Py2
python -m cProfile -o demo-py2.prof demo.py

# Py3
python -m cProfile -o demo-py3.prof demo.py

And view the profiles with snakeviz pip install snakeviz:

# Under Python2's virtual env:
snakeviz demo-py2.prof

# Under Python3's virtual env:
snakeviz demo-py2.prof

Get web page:

NumPy-Python2

NumPy-Python3

And the purple part it time cost on loading packages.

Error message:

Numpy/Python version information:

>>> import sys, numpy; print(numpy.__version__, sys.version)
1.16.4 2.7.16 (default, Apr 12 2019, 15:32:40)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.3)]
>>> import sys, numpy; print(numpy.__version__, sys.version)
1.16.4 3.7.4 (default, Jul  9 2019, 18:13:23)
[Clang 10.0.1 (clang-1001.0.46.4)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0