tag:blogger.com,1999:blog-5440028356946346379.post-81809684998679237502008-05-18T20:11:00.000-04:002008-05-18T20:11:00.000-04:00Thanks for the tip - I didn't know about that.So I...Thanks for the tip - I didn't know about that.<BR/><BR/>So I looked into their source code and found out that the heapq module stores everything in the opposite order from what I do (root node is smallest element - not the largest one). So when I did nlargest, it simply sorted the whole list!<BR/><BR/>nsmallest, which was "equivalent" to what I was doing, works. <BR/><BR/>I also replaced my function with a nonrecursive one - no difference. So at the end: With psyco my version is much faster than heapq, but without it is much slower...Beetle B.noreply@blogger.com