[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Numpy and Numeric surfarray usage



Marcus von Appen wrote:
Hi,

having both, numpy and Numeric now available, I wonder about how to
improve the surfarray interface of pygame. Letting the user use

  pygame.numpyarray   for numpy
  pygame.surfarray    for Numeric

is a bit sloppy. Creating a surfarray wrapper, that lets the user switch
between both might be a good idea here.

What do you think about a single interface, that handles both, numpy and
Numeric using a simple switching method? I thought of putting both into
pygame.surfarray and spend it a new method
  pygame.surfarray.use_array (array_type)

that rebinds the wanted array functions. If the user wants numpy, a
simple
  pygame.surfarray.use_array ("numpy")

will activate numpy for the pygame.surfarray functions. Numeric can be
activated using
  pygame.surfarray.use_array ("numeric")

This also allows to integrate other systems easily without creating tons of
different modules you have to fiddle around with.

To preserve backwards compatibility, "numeric" will be the default for
the next release(s), but might be changed easily later on.

What are your opinions?


I like the idea of combining them into a single interface. But the documentation should warn that NumPy is not backward compatible with Numeric. Having a simple call to use_array makes it appear too easy to switch. In many cases, thought, NumPy is consistent with Numeric.

--
Lenard Lindstrom
<len-l@xxxxxxxxx>