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

[pygame] Numpy and Numeric surfarray usage



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?

Regards
Marcus

Attachment: pgpI4SwA78fz0.pgp
Description: PGP signature