-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
DOC: Fix np.ma.core.doc_note
#16311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOC: Fix np.ma.core.doc_note
#16311
Conversation
@@ -21,6 +21,7 @@ | |||
""" | |||
# pylint: disable-msg=E1002 | |||
import builtins | |||
import inspect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, numpy does not import inspect
at startup.
It might be worth profiling (with -X importtime
) how much this costs us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
full output of `python -X importtime`:
import time: self [us] | cumulative | imported package
import time: 602 | 602 | zipimport
import time: 2711 | 2711 | _frozen_importlib_external
import time: 197 | 197 | _codecs
import time: 1294 | 1490 | codecs
import time: 1077 | 1077 | encodings.aliases
import time: 1700 | 4267 | encodings
import time: 480 | 480 | encodings.utf_8
import time: 326 | 326 | _signal
import time: 668 | 668 | encodings.latin_1
import time: 99 | 99 | _abc
import time: 541 | 640 | abc
import time: 685 | 1325 | io
import time: 182 | 182 | _locale
import time: 392 | 574 | _bootlocale
import time: 119 | 119 | _stat
import time: 481 | 599 | stat
import time: 237 | 237 | genericpath
import time: 562 | 798 | posixpath
import time: 2621 | 2621 | _collections_abc
import time: 1132 | 5148 | os
import time: 465 | 465 | _sitebuiltins
import time: 331 | 331 | types
import time: 586 | 586 | warnings
import time: 332 | 1248 | importlib
import time: 192 | 192 | importlib.machinery
import time: 990 | 2429 | importlib.abc
import time: 232 | 232 | _operator
import time: 560 | 792 | operator
import time: 411 | 411 | keyword
import time: 187 | 187 | _heapq
import time: 560 | 746 | heapq
import time: 338 | 338 | itertools
import time: 574 | 574 | reprlib
import time: 307 | 307 | _collections
import time: 1594 | 4758 | collections
import time: 113 | 113 | _functools
import time: 1161 | 1273 | functools
import time: 2313 | 8343 | contextlib
import time: 530 | 8872 | importlib.util
import time: 155 | 155 | time
import time: 849 | 849 | enum
import time: 118 | 118 | _sre
import time: 402 | 402 | sre_constants
import time: 626 | 1028 | sre_parse
import time: 419 | 1564 | sre_compile
import time: 244 | 244 | copyreg
import time: 932 | 3587 | re
import time: 310 | 310 | token
import time: 1535 | 5431 | tokenize
import time: 211 | 5642 | linecache
import time: 434 | 6076 | traceback
import time: 387 | 387 | _weakrefset
import time: 900 | 7516 | threading
import time: 4012 | 22828 | _virtualenv
import time: 123 | 123 | apport_python_hook
import time: 236 | 358 | sitecustomize
import time: 1962 | 30759 | site
import time: 527 | 527 | numpy._globals
import time: 423 | 423 | numpy.__config__
import time: 328 | 328 | numpy.version
import time: 296 | 296 | numpy._distributor_init
import time: 2188 | 2188 | textwrap
import time: 139 | 139 | math
import time: 332 | 332 | _datetime
import time: 1820 | 2290 | datetime
import time: 3922 | 6211 | numpy.core._multiarray_umath
import time: 570 | 570 | numpy.compat._inspect
import time: 500 | 500 | fnmatch
import time: 263 | 263 | nt
import time: 187 | 187 | nt
import time: 202 | 202 | nt
import time: 1180 | 1830 | ntpath
import time: 219 | 219 | errno
import time: 380 | 380 | urllib
import time: 2662 | 3042 | urllib.parse
import time: 3598 | 9187 | pathlib
import time: 250 | 250 | pickle5
import time: 220 | 220 | _struct
import time: 391 | 610 | struct
import time: 722 | 722 | _compat_pickle
import time: 162 | 162 | org
import time: 40 | 201 | org.python
import time: 33 | 233 | org.python.core
import time: 252 | 252 | _pickle
import time: 2370 | 4185 | pickle
import time: 479 | 14100 | numpy.compat.py3k
import time: 541 | 15211 | numpy.compat
import time: 49 | 15259 | numpy.compat._inspect
import time: 809 | 24465 | numpy.core.overrides
import time: 4390 | 28854 | numpy.core.multiarray
import time: 718 | 718 | numpy.core.umath
import time: 1445 | 1445 | numbers
import time: 661 | 661 | numpy.core._string_helpers
import time: 725 | 725 | numpy.core._dtype
import time: 1934 | 2659 | numpy.core._type_aliases
import time: 1600 | 6362 | numpy.core.numerictypes
import time: 445 | 445 | numpy.core._asarray
import time: 920 | 920 | numpy.core._exceptions
import time: 660 | 1580 | numpy.core._methods
import time: 10467 | 12046 | numpy.core.fromnumeric
import time: 2099 | 14590 | numpy.core.shape_base
import time: 444 | 444 | collections.abc
import time: 741 | 1185 | numpy.core._ufunc_config
import time: 1678 | 1678 | numpy.core.arrayprint
import time: 4784 | 22234 | numpy.core.numeric
import time: 11380 | 11380 | numpy.core.defchararray
import time: 1294 | 1294 | numpy.core.records
import time: 536 | 536 | numpy.core.memmap
import time: 1154 | 1154 | numpy.core.function_base
import time: 437 | 437 | numpy.core.machar
import time: 778 | 778 | numpy.core.getlimits
import time: 1116 | 1116 | numpy.core.einsumfunc
import time: 653 | 653 | numpy.core._multiarray_tests
import time: 4755 | 5407 | numpy.core._add_newdocs
import time: 1182 | 1182 | _ctypes
import time: 715 | 715 | ctypes._endian
import time: 2918 | 3632 | ctypes
import time: 559 | 5372 | numpy.core._dtype_ctypes
import time: 168 | 168 | _ast
import time: 891 | 1058 | ast
import time: 5047 | 5047 | signal
import time: 249 | 249 | _posixsubprocess
import time: 289 | 289 | select
import time: 1807 | 1807 | selectors
import time: 6324 | 13713 | subprocess
import time: 16031 | 29744 | platform
import time: 4032 | 34833 | numpy.core._internal
import time: 637 | 637 | numpy._pytesttester
import time: 2509 | 123614 | numpy.core
import time: 999 | 999 | numpy.lib.mixins
import time: 1522 | 1522 | numpy.lib.ufunclike
import time: 3234 | 4756 | numpy.lib.type_check
import time: 2537 | 7292 | numpy.lib.scimath
import time: 2626 | 2626 | numpy.lib.twodim_base
import time: 502 | 502 | numpy.linalg.lapack_lite
import time: 633 | 633 | numpy.linalg._umath_linalg
import time: 5792 | 9551 | numpy.linalg.linalg
import time: 521 | 10071 | numpy.linalg
import time: 1086 | 11157 | numpy.matrixlib.defmatrix
import time: 641 | 11797 | numpy.matrixlib
import time: 1087 | 1087 | numpy.lib.histograms
import time: 9027 | 10113 | numpy.lib.function_base
import time: 1511 | 1511 | numpy.lib.stride_tricks
import time: 3297 | 26717 | numpy.lib.index_tricks
import time: 3352 | 3352 | numpy.lib.nanfunctions
import time: 5432 | 5432 | numpy.lib.shape_base
import time: 3163 | 3163 | numpy.lib.polynomial
import time: 1947 | 1947 | numpy.lib.utils
import time: 2035 | 2035 | numpy.lib.arraysetops
import time: 1550 | 1550 | weakref
import time: 605 | 605 | numpy.lib.format
import time: 340 | 340 | zlib
import time: 774 | 774 | _compression
import time: 915 | 915 | _bz2
import time: 1096 | 2784 | bz2
import time: 1065 | 1065 | _lzma
import time: 1226 | 2290 | lzma
import time: 182 | 182 | pwd
import time: 118 | 118 | grp
import time: 3794 | 9506 | shutil
import time: 804 | 10309 | numpy.lib._datasource
import time: 1308 | 1308 | numpy.lib._iotools
import time: 2760 | 16532 | numpy.lib.npyio
import time: 2416 | 2416 | _decimal
import time: 465 | 2881 | decimal
import time: 5390 | 8271 | numpy.lib.financial
import time: 617 | 617 | numpy.lib.arrayterator
import time: 877 | 877 | numpy.lib.arraypad
import time: 427 | 427 | numpy.lib._version
import time: 3750 | 81404 | numpy.lib
import time: 447 | 447 | numpy.fft._pocketfft_internal
import time: 3363 | 3810 | numpy.fft._pocketfft
import time: 846 | 846 | numpy.fft.helper
import time: 568 | 5223 | numpy.fft
import time: 516 | 516 | numpy.polynomial.polyutils
import time: 1147 | 1147 | numpy.polynomial._polybase
import time: 3018 | 4681 | numpy.polynomial.polynomial
import time: 2830 | 2830 | numpy.polynomial.chebyshev
import time: 1083 | 1083 | numpy.polynomial.legendre
import time: 1087 | 1087 | numpy.polynomial.hermite
import time: 4190 | 4190 | numpy.polynomial.hermite_e
import time: 1048 | 1048 | numpy.polynomial.laguerre
import time: 1125 | 16040 | numpy.polynomial
import time: 1179 | 1179 | numpy.random._common
import time: 266 | 266 | binascii
import time: 995 | 1261 | base64
import time: 1508 | 1508 | _hashlib
import time: 178 | 178 | _blake2
import time: 239 | 239 | _sha3
import time: 875 | 1291 | hashlib
import time: 800 | 3598 | hmac
import time: 118 | 118 | _bisect
import time: 466 | 583 | bisect
import time: 111 | 111 | _random
import time: 1452 | 2146 | random
import time: 627 | 7630 | secrets
import time: 1914 | 10722 | numpy.random.bit_generator
import time: 864 | 864 | numpy.random._bounded_integers
import time: 587 | 587 | numpy.random._mt19937
import time: 2588 | 14760 | numpy.random.mtrand
import time: 634 | 634 | numpy.random._philox
import time: 380 | 380 | numpy.random._pcg64
import time: 354 | 354 | numpy.random._sfc64
import time: 3111 | 3111 | numpy.random._generator
import time: 860 | 20097 | numpy.random._pickle
import time: 748 | 20844 | numpy.random
import time: 1744 | 1744 | numpy.ctypeslib
import time: 339 | 339 | _opcode
import time: 713 | 1051 | opcode
import time: 1572 | 2623 | dis
import time: 2556 | 5178 | inspect
import time: 4627 | 9805 | numpy.ma.core
import time: 1056 | 1056 | numpy.ma.extras
import time: 875 | 11735 | numpy.ma
import time: 3787 | 265958 | numpy
import time: 339 | 339 | _opcode
import time: 713 | 1051 | opcode
import time: 1572 | 2623 | dis
import time: 2556 | 5178 | inspect
Four lines above are added by import inspect
.
import time: 3787 | 265958 | numpy
And I think this result shows that the cost of import inspect
doesn't affect much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xref #11457. 2% ish seems not too awful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts @hmaarrfk?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the additional import time is OK. It seems to be necessary to provide this desired functionality right?
Any chance you could add a test derived from the issue example? |
It seems that the added test code gives a CI error, but I can't find the cause... |
This fails when PYTOHNOPTIMIZE is set. You can add a
decorator to skip the test. |
@mattip Thanks for your advice. I fixed it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm ok with the 2% increase in import time. Will leave to another maintainer to decide.
Thanks @takanori-pskq |
Fixes #16309