summaryrefslogtreecommitdiff
path: root/numpy/core/arrayprint.py
diff options
context:
space:
mode:
authorMarten van Kerkwijk <mhvk@astro.utoronto.ca>2018-06-14 09:58:25 -0400
committerMarten van Kerkwijk <mhvk@astro.utoronto.ca>2018-06-29 09:50:39 -0400
commitf93a496134f242e6900c029fe4255adce130595f (patch)
treecb88ffbbb1175deec73ebb6ae96d7a198164d96f /numpy/core/arrayprint.py
parenta6383b4d0a5ef51178755b2e1f418265b2304f75 (diff)
downloadnumpy-f93a496134f242e6900c029fe4255adce130595f.tar.gz
MAINT: Improve speed of ufunc kwargs parsing.
Using the realization from inspecting similar CPython code that as we intern string names anyway, comparing keys with possible names by pointer will generally just work. Also rather drastically rewrote, to use a new parser with simple conversion functions to replace part of the enormous switch/case structure, process out separately, and check for duplication after the parsing. Reduces the overhead as follows: ``` import numpy as np a = np.array(1) b = np.empty_like(a) %timeit np.positive(a) # 352->348 ns %timeit np.positive(a, subok=True) # 606->501 ns %timeit np.positive(a, where=True) # 586->503 ns %timeit np.positive(a, where=True, subok=True) # 695->531 ns %timeit np.positive(a, b) # 354->352 ns %timeit np.positive(a, out=b) # 557->480 ns %timeit np.positive(a, out=b, subok=True) # 668->506 ns %timeit np.positive(a, out=b, where=True, subok=True) # 752->536 ns ```
Diffstat (limited to 'numpy/core/arrayprint.py')
0 files changed, 0 insertions, 0 deletions