On 03/08/09 16:08, Dag Sverre Seljebotn wrote:
>>   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.

That is what I had imagined but hope springs eternal.

> 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"?

Indeed, that would be the next obvious step. :)

> 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

I guess that would work too.

> (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.)

Indeed and all those would have to be handled very carefully.

A cheap templating system would be of course to do string substitutions 
and spit out the template instances into a pyx file using Python  -- 
along the lines of numpy's own templating with the .src files.

A more integrated solution would of course be really convenient.

cheers,
prabhu
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to