Real-world Python code 700 times slower than C

Brendan Hahn bhahn at spam-spam.g0-away.com
Wed Jan 9 15:55:57 EST 2002


Chris Barker <chrishbarker at attbi.com> wrote:
>I tried re-writing your code with doubles, and it ended up more than
>four times slower, so now I know why you did it.
>
>Anyone know why this is? I can see that twice as much memory has to be
>allocated, de-allocated, and passed around, but that wouldn't account
>for a 4X slow down. Can anyone offer an explanation?

Processor cache effects are a likely explanation.  Even a small increase in
data volume can have a big impact on speed, since there's enormous
performance gaps between different levels of the memory hierarchy on modern
machines.  Even if all your data can still fit into upper-level caches,
changes in access patterns (e.g. memory stride) can increase your miss
rate.  Similar concerns apply at the level of VM/disk paging.

bhahn at transoft.mmangle.net   <-- unmangle address to reply



More information about the Python-list mailing list