Separated core python implementation from the implementation that uses the numpy external library.