[SciPy-dev] Status of weave

C. Ball ceball at users.sourceforge.net
Thu Jan 17 11:09:54 EST 2008


Jarrod Millman <millman <at> berkeley.edu> writes:
[...]
> As far as I know, no one is answering this question about development
> plans for weave because no one has plans to further develop weave.

Thanks for the information. 

Weave is important for our software [1], so we'd like to try to work
on this problem.

Before we start, any example of an existing converter of this type -
or some guidance about where to start in the weave code - would be
very helpful. 

Presumably the required additions will be quite small: All we need to
do is allow conversion of dtype='O' (as indicated by the example and
error given earlier [2]), since looping through a list of objects, for
instance, is already no problem [3].


Thanks again,
Chris


[1] Topographica (topographica.org) - a package for computational
    modeling of neural maps


[2] http://article.gmane.org/gmane.comp.python.scientific.user/14642


[3] 

import weave

def test_list_loop(alist):
    """
    Loop through alist (assumed to be 2D), setting 'through_loop' to
    be True on every item.
    """
    rows,cols = len(alist),len(alist[1])

    code = """
        for (int r=0; r<rows; ++r) {
            PyObject *alistr = PyList_GetItem(alist,r);
            for (int l=0; l<cols; ++l) {
                PyObject *cf = PyList_GetItem(alistr,l);
                PyObject_SetAttrString(cf,"through_loop",Py_True);
            }
        }
    """

    weave.inline(code,['rows','cols','alist'],local_dict=locals())



class SomeObject(object):
    pass

list_of_objects = [[SomeObject(),SomeObject(),SomeObject()],
                   [SomeObject(),SomeObject(),SomeObject()]]

test_function(list_of_objects)




More information about the SciPy-Dev mailing list