Source

pygame / lib / surfarray.py

Diff from to

File lib/surfarray.py

 
 Supported array types are
 
+  numpy
   numeric
-  numpy
 
-The default will be Numeric, if installed. Otherwise, numpy will be set
-as default if installed. If neither Numeric nor numpy are installed, the
+The default will be numpy, if installed. Otherwise, Numeric will be set
+as default if installed. If neither numpy nor Numeric are installed, the
 module will raise an ImportError.
 
 The array type to use can be changed at runtime using the use_arraytype()
 
 # Try to import the necessary modules.
 try:
+    import pygame._numpysurfarray as numpysf
+    __hasnumpy = True
+    __arraytype = "numpy"
+except ImportError:
+    __hasnumpy = False
+
+try:
     import pygame._numericsurfarray as numericsf
     __hasnumeric = True
-    __arraytype = "numeric"
+    if not __hasnumpy:
+        __arraytype = "numeric"
 except ImportError, msg:
     __hasnumeric = False
 
-try:
-    import pygame._numpysurfarray as numpysf
-    __hasnumpy = True
-    if not __hasnumeric:
-        __arraytype = "numpy"
-except ImportError:
-    __hasnumpy = False
-
 if not __hasnumpy and not __hasnumeric:
     raise ImportError, "no module named numpy or Numeric found"
 
+from _arraysurfarray import blit_array
+
 def array2d (surface):
     """pygame.surfarray.array2d (Surface): return array
 
         return numpysf.make_surface (array)
     raise NotImplementedError, "surface arrays are not supported"
 
-def blit_array (surface, array):
-    """pygame.surfarray.blit_array (Surface, array): return None
-
-    Blit directly from a array values.
-
-    Directly copy values from an array into a Surface. This is faster
-    than converting the array into a Surface and blitting. The array
-    must be the same dimensions as the Surface and will completely
-    replace all pixel values.
-
-    This function will temporarily lock the Surface as the new values
-    are copied.
-    """
-    if __arraytype == "numeric":
-        return numericsf.blit_array (surface, array)
-    elif __arraytype == "numpy":
-        return numpysf.blit_array (surface, array)
-    raise NotImplementedError, "surface arrays are not supported"
+##def blit_array (surface, array):
+##    """pygame.surfarray.blit_array (Surface, array): return None
+##
+##    Blit directly from a array values.
+##
+##    Directly copy values from an array into a Surface. This is faster
+##    than converting the array into a Surface and blitting. The array
+##    must be the same dimensions as the Surface and will completely
+##    replace all pixel values.
+##
+##    This function will temporarily lock the Surface as the new values
+##    are copied.
+##    """
+##    if __arraytype == "numeric":
+##        return numericsf.blit_array (surface, array)
+##    elif __arraytype == "numpy":
+##        return numpysf.blit_array (surface, array)
+##    raise NotImplementedError, "surface arrays are not supported"
 
 def map_array (surface, array):
     """pygame.surfarray.map_array (Surface, array3d): return array2d