[Slightly-OT] Wasn't Google supposed to be "avid Python-Users" ?

Michael Hudson mwh at python.net
Thu Feb 7 14:25:54 CET 2002

Michael Abbott <michael at rcp.co.uk> writes:

> Michael Hudson <mwh at python.net> wrote in news:uk7tpa574.fsf at python.net:
> > Michael Abbott <michael at rcp.co.uk> writes:
> > 
> >> I reckon to pay a cost of perhaps a factor of 100 in raw CPU for the 
> >> privilege of using Python. 
> > 
> > But not over Java, surely?  I guess a JIT or native compilation will
> > help, but...
> I think so.  Java byte codes are pretty low level, and don't have to do 
> very much, and of course JIT or native compilation can be *very* effective.  
> Python byte codes are, on the other hand, much more powerful, and have to 
> do quite a lot of run-time work.

Fair enough.  Don't know much about the Java world.

> If you're doubtful, take a quick peek at what the Python byte code 
> interpreter does to implement a method call (I'm thinking of call_object in 
> ceval.c).  There's nothing wrong with this (that's not my point), but 
> there's quite a lot of work to be done (including memory allocation, I'm 
> afraid).

I do know quite a lot about the Python world though :)

> This is one of the most widely used operations in the language (excepting, 
> perhaps, method lookup), and can be reduced in a natively compiled language 
> to a small handful of instructions or even eliminated (when we're lucky).
> My factor of a 100 is a guess; am I wrong?  I believe it's fair.

In my experience, it's a bit of an over-estimate.  Depends what you're
doing, of course.  I find I tend to optimize the straight line bits of
code, which probably doesn't yield the greatest improvement, in some
sense, but not writing the not-straight-line bits of code in C is the
reason I use Python in the first place...


  Every day I send overnight packages filled with rabid weasels to
  people who use frames for no good reason.
                             -- The Usenet Oracle, Oracularity #1017-1

More information about the Python-list mailing list