Prabhu Ramachandran wrote: > On 03/08/09 04:07, Dag Sverre Seljebotn wrote: >> Anyway, I feel myself that this has a better feel than a new array type, >> as it makes use of the buffer interface and so bridges better with >> Python-land. >> >> My proposal is here: >> http://wiki.cython.org/enhancements/buffersyntax > > This looks really nice. I'm just a little curious about one little > feature, would this support resizing the buffer? i.e. could I do > > def f(int[:] arr): > cdef int i > # ... > arr.append(i)
No, this would never happen. This is defined as syntax candy for PEP 3118, which exports a view to allocated memory but doesn't say anything about how that memory is allocated or deallocated. I believe we must solve this, but in a different way. Given that we get a "fast list", wouldn't we then want a "fast dict"? Adding a type templating mechanism to Cython is not out of the question I think, there was some talk 3/4 year ago. But now I myself believe the most promising option is to wrap C++ in a very good way, so that one can do something along the lines of cdef cpp.vector[int] arr = cpp.vector[int]() cdef cpp.map[str, cpp.vector[int]] map = cpp.map[str, cpp.vector[int]]() arr.push_back(3) map[40] = arr (Yes, those lines raises about 10 questions about reference counting vs. copy-by-value semantics; making C++ access feel Pythonic is part of such a challenge IMO.) Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
