Python using NaN or None as sentinel

Comparing to None instead of NaN is over 50 times faster in Python.

speed improvement test None vs. nan in Python


Python 3.6.0 IPython 5.1.0

from numpy import isnan
%timeit ~isnan(0)

1000000 loops, best of 3: 1.68 ┬Ás per loop

%timeit 0 is not None

10000000 loops, best of 3: 28.4 ns per loop