Speed Comparison Perl Python & C
Dave Cole
djc at object-craft.com.au
Wed Jul 7 00:42:35 EDT 2004
Cameron Laird wrote:
> In article <du7y8qlhbd1.fsf at amadeus.cc.tut.fi>,
> Ville Vainio <ville at spammers.com> wrote:
> .
> .
> .
>
>>query. Actually, Python code might even be faster in circumstances
>>like these, because you can write more sensible algorithms w/o
>>investing a week of debugging. So caching data in memory becomes more
>>appealing.
>
> .
> .
> .
> Yup; I'm now sufficiently arrogant/provocative/confident/experienced/...
> to tell people to expect that their Python codings will be *faster* than
> what they achieve with C.
I can cite an example of this from my own experience.
My first implementation of the Sybase DB-API implemented most of the
interface in C for speed. I had only been using Python for a couple of
weeks when I developed that version. After a while I started to think
about supporting array binding to fetch results from the server more
than one row at a time. The amount of work necessary to make the C code
support array binding was more than I was prepared to undertake.
I wanted to support array binding so I decided to simply wrap the Sybase
CT API and implement the DB-API in Python on top of the wrapping. This
was a huge win because I was able to implement a feature that would
probably have been too hard in plain C (at least for my puny brain).
So I agree, in some (maybe even many) cases the Python implementation
will be faster than the C implementation purely because of the increased
sophistication of the solutions you are able to implement.
- Dave
--
http://www.object-craft.com.au
More information about the Python-list
mailing list