Implementing file reading in C/Python

Johannes Bauer dfnsonfsduifb at gmx.de
Fri Jan 9 14:48:30 CET 2009


mk schrieb:
> Johannes Bauer wrote:
> 
>> Which takes about 40 seconds. I want the niceness of Python but a little
>> more speed than I'm getting (I'd settle for factor 2 or 3 slower, but
>> factor 30 is just too much).
> 
> This probably doesn't contribute much, but have you tried using Python
> profiler? You might have *something* wrong that eats up a lot of time in
> the code.

No - and I've not known there was a profiler yet have found anything
meaningful (there seems to be an profiling C interface, but that won't
get me anywhere). Is that a seperate tool or something? Could you
provide a link?

> The factor of 30 indeed does not seem right -- I have done somewhat
> similar stuff (calculating Levenshtein distance [edit distance] on words
> read from very large files), coded the same algorithm in pure Python and
> C++ (using linked lists in C++) and Python version was 2.5 times slower.

Yup, that was about what I had expected (and what I could well live
with, it's a tradeoff).

Thanks,
Kind regards,
Johannes

-- 
"Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit,
verlästerung von Gott, Bibel und mir und bewusster Blasphemie."
         -- Prophet und Visionär Hans Joss aka HJP in de.sci.physik
                         <48d8bf1d$0$7510$5402220f at news.sunrise.ch>



More information about the Python-list mailing list