On Tue, May 5, 2009 at 4:17 AM, Casey Duncan <ca...@pandora.com> wrote:
> Just to clarify my position, performance is a secondary concern, primarily > I'm concerned about intuitiveness and convenience. I suspect an immutable > vector type will cause a regular amount of mail traffic asking how to mutate > them and why that is not possible. I could be wrong, but I think many folks > will be surprised by an immutable vector class. > > I'm +0 on immutable vectors, they're certainly much better than nothing, > but I personally would prefer mutable. > > To make immutable types more performant, you should look at the > implementation of tuples in Python. tuple instances are pooled so they can > be recycled, saving a lot of memory management overhead. I did a similar > thing for vectors in Lepton with good results. > > -Casey > +1 for memory pools. Memory is the main overhead for performance these days. Anything to avoid a copy or a malloc/mmap, and to group areas of memory together for reading. Mutable vectors fail the use cases: - use Vector as a proxy for some values in a larger array. eg, in numpy I can do reference_to_big_array = bigarray[1:3] - consistency with Rect, list, numpy/Numeric arrays, python arrays. Another use case is consistency with most other Vector types in CS. I think most Vectors are mutable. - allow people to use vectors like how they are used in most graphics literature. cu,