Movatterモバイル変換
[0]ホーム
python on the smalltalk VM
Michael Hudsonmwh21 at cam.ac.uk
Fri Apr 20 03:34:54 EDT 2001
Carlos Ribeiro <cribeiro at mail.inet.com.br> writes:> At 23:03 19/04/01 +0100, Michael Hudson wrote:> >Douglas Alan <nessus at mit.edu> writes:> >> > > After many years of research, they came up with a compiler for Self> > > that would generate code that runs about one half to one third the> > > speed of compiled C code. This is 30 to 50 times faster than> > > Python.> >> >No it isn't. At least, not for me. Generally I find that fairly> >optimized C modules are about 40-60 times faster than really optimized> >Python (I'm better at Python than C). Obviously "it depends", but> >I've found these numbers to be fairly consistent over a variety of> >tasks.>> For all reasonable applications that I can think of, 30-50 compared> to 40-60 is about the same (at least is the same order of> magnitude).Doug was claiming 30-50 times faster than Python is one third to onhalf the speed of C, i.e. C was 60-150 times faster than Python.> Anyway, what really surprises me is the magnitude of the difference> between C and Python.Really? It always surprises me how small it is.> It does make sense to have a big difference - interpreted languages> will always be slower - but the higher level of abstraction in> Python should allow for a smaller difference.But that would require a seriously smart comiler to take advantage ofthe higher abstraction, no?It would probably be the case that as you rewrite larger portions ofyour code in C, the difference would get smaller - the numbers I amtalking about are for rewriting fairly simple, tightly specifiedfunctions with little dynamism.> It brings the question: how are these numbers measured?In my case, by identifying hot spots in my code, trying to optimizethe snot out them in Python, rewriting them in C and them timing thedifference between my fastest C version and my fastest Python version.> For some applications (such as text file processing) I doubt that> the difference could be so big, specially if you know how to> optimize your Python code.I suspect that the main speed up for rewriting string bashing code inC is from being able to avoid allocating memory. This is just a hunchthough, and given that it's about performance, it's almost certainlywrong.Cheers,M.-- ROOSTA: Ever since you arrived on this planet last night you've been going round telling people that you're Zaphod Beeblebrox, but that they're not to tell anyone else. -- The Hitch-Hikers Guide to the Galaxy, Episode 7
More information about the Python-listmailing list
[8]ページ先頭