Move entity.py to C++/Cython