On Feb 17, 3:05 pm, [EMAIL PROTECTED] wrote: > I researched this for some Java I wrote. Try to avoid shuffling > physical memory - you'll write a lot less code and it will be faster, > too. > > Use an "allocated" list and an "available" list. Keep them in address > order. Inserting (moving list elements from insertion point to end) > and deleting (vice-versa) are near-zero cost operations on Intel > boxes. ( Two millis to move a million ints at 1GHz 5 years ago when I > wrotehttp://www.martinrinehart.com/articles/repz.html- probably half > that today.)
It seems to me that another, perhaps better strategy, would be to allocate a large heap space, then store a pointer to the base of the heap, the current heap size, and the beginning of the free memory. When you need to 'allocate' more room, just return a pointer to some location in the heap and increment the start-of-free-memory pointer. That way, allocation really IS free, more or less. Wouldn't that be more efficient? Perhaps I'm missing something. As a side note, I'm new to Usenet, so I'm not exactly sure... are 'tangents' like this - since this IS a Python newsgroup, after all - okay? Anyway, thanks for the suggestion. -- http://mail.python.org/mailman/listinfo/python-list