A 'Python like' language

Mark Hahn mark at prothon.org
Tue Mar 30 09:14:32 CEST 2004


> Stackless-type systems tend to make this rather more convoluted than just
making a C function call.

I define a function call as:

call_func(ist, self, func_sym,  parm_cnt, lbl_val_arr, dyn_locals);

This call is the same for interpreted Prothon or internal C code.  It has
the self object, the symbol telling the function name, and the passed
parameters.  ist is a struct passed around everywhere to keep interpreter
state and keep things re-entrant.  dyn_locals is used for dynamic local
compatilility in C (which has never been used and may be pulled).
lbl_val_arr is a C array (length of parm_cnt) of object pairs of labels (sym
objects) and value objects.  The labels allow one to do func(x=value).
Usually, internally the labels are NULL.  This structure supports
func(*list, **dict) even internally.

You may call this convoluted if you wish.


"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