Ah I see. Well, Cython's coming support won't be much help either then...(if you want to, say, wrap a sparse matrix lib or similar).
Anyway: - Don't do arr[i][j], do arr[i,j]. - Do override __getitem__! (if necesarry in a new object returned from a proprty, but in this case I don't see any need for properties) - Slices etc are no problem, you can check the index parameter to __getitem__ for slice objects. Yes, you must manually implement slices etc., but if NumPy doesn't cover your case this follows anyway! -- it's not like Python or Cython would be able to guess what a slice should represent or how it should be implemented in your more complex problems. Dag Sverre Seljebotn -----Original Message----- From: Mattia Ziulu <[email protected]> Date: Friday, Aug 28, 2009 3:50 pm Subject: Re: [Cython] Expose a *float element to Python namespace To: [email protected]: [email protected] >On Fri, Aug 28, 2009 at 3:29 PM, Dag Sverre Seljebotn ><[email protected]> wrote: > Two answers: > 1) In about half a year, there will likely be a released version of Cython > with built in capability to do this kind of wrapping. > > >This is awesome! > > 2) NumPy NumPy NumPy! Doing this without using NumPy is a waste of time IMO. > Use the PyArray_New... function in the C api to create array backed by your C > struct. (I remember posting a howto to Jon Olav Vik here on the list around > June). > > >No can do. Or better yet, yes could do, but the whole point here is that my >MatrixFloat gimmick is all a big test for something a lot more complicated and >generalized, where Numpy wouldn't be useful at all. Let's just say that I'm >using this 'project' to wrap my mind around this whole (and for me new) world >of wrapping and exposing and whatnot, and being a matrix class something >pretty easy to set up (in a fairly basic way anyway) I choose to implement >this. > I've looked at numpy for some inspiration though, both docs and source code, > but there are not a lot of useful things in it that could be useful in this > context too, I'm afraid. >
_______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
