[Python-Dev] Re: buglet in interaction between pygame, Numeric & copy in Python 2.3 (original) (raw)

Jack Jansen Jack.Jansen@cwi.nl
Fri, 1 Aug 2003 00:01:28 +0200


On donderdag, jul 31, 2003, at 23:14 Europe/Amsterdam, Alex Martelli wrote:

E.g., the way src/surfarray.c does it in pygame (simplifying just a bit):

#include <Numeric/arrayobject.h> static PyObject* pixels3d(PyObject* self, PyObject* arg) { PyObject* array; ... array = PyArrayFromDimsAndData(3, dim, PyArrayUBYTE, startpixel); if(array) { ((PyArrayObject*)array)->flags = OWNDIMENSIONS|OWNSTRIDES|SAVESPACE; ... etc, finish initializing the array object } return array; }

Are you using a static build? Because if you use a dynamic build then the PyArray_ functions are actually funky macros that call through a vector, and you have to add an explicit call the the "import_array()" matrix somewhere. And this imports Numeric and initializes the vector.

No, wait! import_array() does a PyImport_ImportModule("_numpy"), not PyImport_ImportModule("Numeric"). So maybe fixing this is only a question of importing Numeric, and getting Numeric._numpy._ARRAY_API in import_array().