Nums! A new name for the group (Numpy, Numeric, Numarray) is Nums.
+1 for polymorphism. Although the current api is good too. You can always check the return type if you need to know its type. The nums are similar enough for lots of uses. Often only one type will be installed on someones machine. pixels.as_nums() ? which returns a globally registered num? Or as_globally_registered_array() for a really long name. Ok, I can't think of a good name for it. Another option... Maybe instead of surf.pixels.as_something()... surf.pixels surf.pixels_numpy surf.pixels_numarray surf.pixels_numeric surf.pixels_yet_another_numeric_type_when_it_comes_up surf.pixels_num The pixels_num would be the globally registered type. There would still be surf.pixels the same as it is now. The globally registered type would be discovered and set the same way that pyopengl does. What about that? On 6/14/06, Alex Holkner <[EMAIL PROTECTED]> wrote:
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.
