[wxpython-users] GSoC 2008 application
Christopher Barker
Chris.Barker at noaa.gov
Tue Apr 1 09:49:50 PDT 2008
Nitro wrote:
> Am 31.03.2008, 10:45 Uhr, schrieb Christopher Barker
>> The alternative is to use the "array interface" which is an interface
>> specification for array-like objects -
> I guess you are referring to this:
> http://numpy.scipy.org/array_interface.shtml .
Yes. Also, there is the new "extended buffer" interface, slated for
py3k. I'd ask on the numpy list for advise as to the best way to go.
> 1. User creates a numpy array (supports the array interface)
> 2. wxImage is extended with another constructor (or a standalone method
> is added which creates a wxImage object) which takes a python object and
> checks whether it supports the array interface.
yes.
> 3. If it does, some sanity checking is performed on the type of the
> data. If this test succeeds, the data can be passed to wxImage, probably
> using the default constructor with static_data=true.
yes.
> SetData() seems to
> take ownership of its data so I think it won't work. I need to check
> with the wxWidgets sources to ensure data copying is minimized.
you will need to do some research. On the one hand, we want to pass
pointers rather than copying data, for efficiencies sake. On the other
hand, we want memory management to work -- it's a tricky balance.
> 4. For classes like wxBitmap there's no version which supports something
> along the lines of static_data = true. I guess this is because wxBitmap
> is a handle around a platform-specific bitmap. So this needs some
> special handling. Btw, I just found out that the RawBitmapAccess demo
> sample already features wx.Bitmap and numpy integration via
> wx.BitmapFromBuffer!
exactly -- cleaning that up a bit with the array protocol would be
great. Maybe just a bit more error checking.
> For retrieving data, methods could be added which retrieve the data as a
> numpy array.
Well, to get a numpy array, you need the numpy headers, etc. So I think
what we want is for wxImage (and wxBitmap?) to support the array
interface, so you can do:
numpy.asarray(My_wxImage)
and get a numpy array that shares data with the wx.Image. Memory
management issues, but that's how the interface is supposed to work, so
that wxPython doesn't need to know about numpy arrays, only about the
array interface.
> Apart from using the array interface, there's also the possibility to
> use numpy's typemaps, create an additional dll for wxPython which is
> dependent on the numpy api and which is only loaded when numpy is
> present. However, I favour the looser "array interface" way.
I agree -- I think we can get everything we want without any extra
modules or dependence on numpy.
>> While we look at this, we should take a look and see if some
>> GraphicsContext optimization could take advantage of this too.
>
> Yes, methods like DrawLines would surely benefit from this. I guess
> FloatCanvas with a GC backend would make for a nice, real-world
> performance test for this :-)
exactly!
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the wxpython-users
mailing list