[Python-Dev] Python is faster than C

Moore, Paul Paul.Moore at atosorigin.com
Mon Apr 5 08:54:38 EDT 2004


From: Gareth McCaughan
> Mhm. And what happens if you want to sort something other
> than integers? Say, Python objects with their own comparison
> operators? Or even just (int,int) tuples?

I got the impression that Armin's point was that Psyco can optimise
the integer case *if* the code is in Python, but not if it's in C.

I suspect that sort isn't a good example here, but heapq may be. By
recoding it in C, the chance of getting of type-specific specialised
speedups is lost, in favour of a (possibly) smaller speedup across
the board. To get a feel for whether the right tradeoff has been
made, you'd need to analyze real use cases in some detail (which
may not be worth it).

[Armin, how does Psyco + a Python sort compare against timsort on
more general objects?]

Hmm. I'm torn. On the one hand, it's really cool that Python+Psyco can
out-perform C (another argument against the knee-jerk "recode bits in
C" reaction). But my gut feel is that not enough people use Psyco to
make this a good answer yet. On the third hand, if we recode chunks of
the stdlib in C, do we kill too many chances for Psyco to work its
magic?

Time for Psyco to go into the stdlib, maybe? :-)

Paul.



More information about the Python-Dev mailing list