As I understand this, the KMP function uses an optimal algorithm, while the indexOf version uses a suboptimal algorithm but takes advantage of a native (C) implementation found in the standard library.
It follows that the fastest approach should be to implement the KMP algorithm natively, using Pyrex rather than C should make this fairly trivial.