When will Java go mainstream like Python?
greg.ewing at canterbury.ac.nz
Thu Feb 25 09:43:08 CET 2010
Lawrence D'Oliveiro wrote:
> And then there’s caching. Modern CPUs owe most of their speed to assumptions
> that programs will obey locality of reference. Pointer-chasing is a cache-
> hostile activity.
Another thing to consider is the rate at which garbage is
created. Java's fundamental types (ints, floats, etc.) are
unboxed, and objects are only used for relatively heavyweight
things. So you can do quite a lot of useful computation in
Java without creating any objects or leaving behind any
In Python, on the other hand, you can't even do arithmetic
without creating and destroying intermediate objects at
every step. Collecting those objects promptly means that
the same areas of memory tend to get re-used over and
over, resulting in better cacheing behaviour.
So I don't think you can assume that just because Java's
garbage collection scheme works well for Java that it would
also necessarily work well for Python.
More information about the Python-list