In order to speed up the python code easily, I introduced numba. However, it was not possible to install with pip alone, so record the installation procedure as a memorandum.
It seems that llvm
and ʻenum34are required separately. In particular, llvm seems to need 3.7.x instead of the latest 3.8.x. Tap
homebrew / versionsto install. Also, don't forget to set the environment variable
LLVM_CONFIG`.
brew tap homebrew/versions
brew install homebrew/versions/llvm37
export LLVM_CONFIG=/usr/local/Cellar/llvm37/3.7.1/bin/llvm-config-3.7
pip install enum34
pip install numba
So that it works even in the environment where numba is not installed If it cannot be imported, replace it with a decorator that does nothing.
try:
from numba import jit
except ImportError:
def jit(*args, **_kwargs):
if len(args) > 0 and hasattr(args[0], "__call__"):
return args[0]
else:
def _(func):
return func
return _
If you want to use something other than @ jit
, define the same thing.
Also, in this case, the type specification must be passed as a character string instead of an object.
Is the literature around here?
Recommended Posts