[Python-Dev] Re: buglet in interaction between pygame, Numeric & copy in Python 2.3
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 = PyArray_FromDimsAndData(3, dim, PyArray_UBYTE, startpixel);
> if(array)
> {
> ((PyArrayObject*)array)->flags =
> OWN_DIMENSIONS|OWN_STRIDES|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().
--
- Jack Jansen <Jack.Jansen@oratrix.com>
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- Emma
Goldman -