Numba has an amazing ability to speed up the cycle with JIT compilation. The key turning point is that when using numpy you cannot create new arrays . Fortunately, most numpy functions include an optional parameter outto write output to - except numpy.sort. The most obvious alternative is numpy.ndarray.sortthat which is in place,
out
numpy.sort
numpy.ndarray.sort
@njit("void(f8[:])") def sort_inplace(arr): arr.sort()
but it does not compile,
... ... ... /Users/duckworthd/anaconda/lib/python2.7/site-packages/numba/typeinfer.pyc in propagate(self) 293 print("propagate".center(80, '-')) 294 oldtoken = newtoken --> 295 self.constrains.propagate(self.context, self.typevars) 296 newtoken = self.get_state_token() 297 if config.DEBUG: /Users/duckworthd/anaconda/lib/python2.7/site-packages/numba/typeinfer.pyc in propagate(self, context, typevars) 112 raise 113 except Exception as e: --> 114 raise TypingError("Internal error:\n%s" % e, constrain.loc) 115 116 TypingError: Internal error: Attribute 'sort' of array(float64, 1d, A) is not typed
With the exception of reimplementing the sorting algorithm, is there a way to sort the numpy array in a JIT-compiled numba loop?
Numba "nopython", , , ndarray.sort(). "python", , python, ndarray.sort(), C, . numba github.
: numba nopython, , python. , ndarray.sort(), , numpy.arange(), , ( ndarray.sort() numpy.arange() , , , , ).
, : jit njit, numba ndarray.sort() nopython, .
Source: https://habr.com/ru/post/1542428/More articles:Interesting behavior with infix notation - scalahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1542424/alias-to-create-aliases&usg=ALkJrhjJaYoSqI1SMZceW-FhVnt7pxAJlgDifference between Hash32 and Hash in Java string Object - javaPassbook generates PKPass error - iosHow to execute for loop in packages? - pythonAmazon sns & sqs messages with java - javaattr_accessor does not work Rails 4 - ruby-on-railsOpenCV Manager Unable to detect hardware in Galaxy S5 - androidC ++ performs a function from memory - c ++https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1542433/whitespace-causing-divs-to-stack-in-pure-css&usg=ALkJrhglQL-YzVjpSspfbSUEklcNyEfAfQAll Articles