After some experiments with my own AC code from 2009, that uses the no longer available psyco (as all the other AC submissions do as well - you can conclude that by looking at the memory usage), I firstly found out, that it is possible to get AC even with actual "pure Python" versions (Python 3 as well).
Then I compared the runtime of my code to your code using some random generated data with the result, that your code is about 1.5-2 times slower than my AC code. I tried some minor approvements (there was not much to do) to your approach, but that also let to TLE.
So I conclude, that the builtin heap-functions are either not fast enough or - that's what I observed in other cases - the import of the needed module is too expensive, independend from its usage. So, local comparisons not always match the SPOJ results.