Cythonで'bool' is not a constant, variable or function identifier
Cythonである変数がbool型であるかを調べるのに"isinstance(val, bool)"のようにしたところ, "'bool' is not a constant, variable or function identifier"と怒られた.
どうも, Cythonで扱うbool型には二種類あるらしく*1, libcppのboolを用いているとこのエラーが出る. Pythonにおけるbool型を得たい場合はcpythonのものを利用するようにすれば良い.
from libcpp import bool from cpython import bool as bool_t val = True if isinstance(val, bool_t): do_something(<bool> val)
https://github.com/cython/cython/wiki/FAQ#how-do-i-declare-an-object-of-type-bool
*1:bintも加えれば3種類.