Python / C: small runtime difference?

Martin Schneider martin.schneider at illusion-factory.de
Tue Sep 9 05:06:01 EDT 2003


Hi!

I want to extend Python with a C module, so to get the technology clear, I
wrote a Bubblesort over 10.000 elements in Python and in a C extension for
Python and got it running (YES! :-))

But...

The Python Bubblesort runs 103 seconds, the C extension Bubblesort runs 28
seconds, this is about 1:4, which is far worse than I expected (assumed
about 100:1 or alike).

The interface overhead is neglectable (1/10 second).

Is this normal?

I am using Borland's free compiler BCC on Win32 and Python 1.5.2 (because
the customer uses other modules which do not run under newer versions).

Thank you for your ideas!

Martin






More information about the Python-list mailing list