Moved hash to cython to avoid using Python longs