Add a pure-python alternative implementation, making this compatible with PyPy.