[pypy-dev] More on optimization

Armin Rigo arigo at tunes.org
Thu Nov 4 23:45:15 CET 2004

Hi Samuele,

On Thu, Nov 04, 2004 at 03:51:50PM +0100, Samuele Pedroni wrote:
> >it depends on how you implement things, realloc needs to be expressed as 
> > alloc and copy but I don't see what force you to incapsulate the array
> >in an extra layer object.
> >
> oops, sorry now I see, you want RPython lists to be lists, that's 
> probably different that what we wanted originally.

No, I'm thinking about the following problem: suppose that an RPython list is
meant to represent an expensively resizeable array.  The problem with
implementing that using a bare Java array is that when you realloc and copy,
all the references to the array should be updated to point to the new array.  
This is impossible unless you either track all references using complex
analysis, or you encapsulate the array in another Java object.  It's like,
say, in Python where you cannot use bare strings to implement mutable strings:
although you can use slices and concatenation to build a modified string, you
cannot update all the places that pointed to the old string to now point to
the new string.  So you have to encapsulate the string in an instance.


More information about the Pypy-dev mailing list