A 'Python like' language

Mark Hahn mark at prothon.org
Tue Mar 30 02:41:02 EST 2004


If you were designing a new interpreter, would you consider reference
counting an evil pain for C coders (as I did) and use some other GC, or do
you think I made a mistake?  Is there a compromise?


"Greg Ewing (using news.cis.dfn.de)" <ieyf4fu02 at sneakemail.com> wrote in
message news:c4am81$2ha0mj$1 at ID-169208.news.uni-berlin.de...
> Mark Hahn wrote:
> >>But I wonder what effect the lack of reference counting has
> >>on cache-friendliness of the memory management system.
> >
> > I don't see how the lack of something could hurt the cache.  Do you mean
the
> > garbage colector?
>
> A running Python program creates and discards certain kinds
> of objects (e.g. integers, tuples, stack frames) at a very
> high rate. Due to reference counting, the fact that these
> objects have been discarded is discovered very quickly, and
> their memory released. Subsequent allocations are likely to
> re-use the same memory, which is likely to be in cache.
>
> A pure mark-and-sweep system, on the other hand, tends to
> keep on allocating fresh memory and letting the garbage
> objects pile up until there is no more fresh memory, only
> then pausing to reclaim the garbage. This is a very bad
> access pattern for cache purposes.
>
> Back when the addition of a mark-and-sweep collector to
> Python was being debated, this argument was put forward as
> a reason why replacing reference counting with mark-and-sweep
> wouldn't obviously be an improvement, and could make things
> worse.
>
> Python currently has both reference counting *and* mark
> and sweep, which sounds redundant, but the combination seems
> to work very well.
>
> > The interpreter supports C code calling Prothon code and vice versa.
>
> I don't doubt that it's possible, I was just wondering how
> easy it is. Stackless-type systems tend to make this rather
> more convoluted than just making a C function call. I'll take
> a look at the code some time and find out.
>
> -- 
> Greg Ewing, Computer Science Dept,
> University of Canterbury,
> Christchurch, New Zealand
> http://www.cosc.canterbury.ac.nz/~greg
>





More information about the Python-list mailing list