Peter Shinners wrote:

Forwarded message from Mike Fletcher:
---------------------------------------------------------
I'm wondering if we can just always have SDL functions return new
"ctypes" style arrays. Then provide convenience functions for wrapping
those into array types for other libraries.
   pal = mysurf.format.palette
   palette = SDL.numpy.Convert(pal.ncolors, pal, colors)

Then again, we may prefer more specific array building functions.
   palette_array = SDL.numeric.PaletteArray(mysurf.format.palette)
   pixel_array = SDL.numeric.PixelsArray(mysurf)

I'd considered this, but it winds up *requiring* that code be written
explicitly for the ctypes version of the library, which I'd defined (for
my project, SDL-ctypes) as not being allowable (since if you've written
the code for Numeric + PyOpenGL you always expect to get back
Numeric-array-compatible objects).

Sorry for the delay in responding to this,
Mike
I think I've missed some of this thread. Mike, you also have a SDL-ctypes project?

For (my) SDL-ctypes, there are no compatibility issues: there is no other SDL wrapper for Python (PySDL being abandoned).

The way the current API works, if a user wants a numpy array:

 pixel_array = mysurf.pixels.as_numpy()

Yes, this requires that all users need numpy installed, but then, that's probably because the program is going to be using numpy functions anyway. Numpy/numeric/numarray, while similar, are by no means identical or interchangeable.

Alex.

Reply via email to