Stackless/microthreads merge news

Jeff Senn senn at maya.com
Wed May 17 09:43:01 EDT 2000


Glyph Lefkowitz <glyph at twistedmatrix.com> writes:
> ObOnTopic -> One thing that's been bugging me lately though; Java is
> definitely faster than python, but Python and Java both use virtual
> machines.  The difference, as far as I can tell, is that Python
> objects (namespaces, classes, class instances, etc) are actually all
> *hashtables*.  Java's are similiar to C structs, at least in how bytes
> are arranged, linked, and accessed.  Java's speed advantage is
> significant, but from what I've seen so far, it doesn't seem to be the
> massive leap beyond python that I'd expect.
> 
> Is there a good technical reason for this, or is it just a poor
> implementation?  I haven't had a chance to read enough of Python's
> sources yet, I guess, but is it doing any tricks with attribute access
> to make them faster than regular hashtables?  (or is my estimation of
> the speed difference really just erroneous?)
> 
> The obvious next question is "if not, why not?" but I think I
> understand that, if it's the case ^_^.

Hm...I haven't actually tested -- so this is speculation based on
experience and tests of similar scriptable/VM systems in the past.

I suspect that many of the extra cycles in Python are in heap
management -- in Python objects tend to be small and contain more
pointers to other things.  A Python object that has 3 integer members
is (at least) 4 allocations.  There is overhead in both size and (more
significantly) number of heap alloc/deallocations -- however the power
you buy back is being able to say:

any_random_object.never_before_mentioned_name = any_kind_of_thing

Additionally there is the JIT issue ... which I'm not sure I
have a good intuitive grasp on -- and the fact that, since Python has
function pointers (and uses them!) a lot more (run) time is spent
hunting for the correct bit of code to execute.

But, as you say, the differences are not vast.  I suspect that if
Python had the resources of a Sun or MS behind it, it would get pretty
fast -- but probably never as fast as a language w/o some of the
"features" that Python has.

-- 
-Jas
MAYA Design





More information about the Python-list mailing list