Replace Python prediction function with C++

GPDB 4.2.3 bug does not like Python, and on the other hand, C++ is
faster.