[SciPy-user] vectorizing methods?

Greg Novak novak@ucolick....
Sat Jul 14 18:31:59 CDT 2007

Is there a preferred way to vectorize methods, rather than functions?
The obvious thing doesn't work:

class foo:
    def bar(self, x): pass
    bar = vectorize(bar)

I came up with this:

class foo:
    __vectorMethods = ('bar', )

    def __init__(self, n):
        for name in self.__vectorMethods:
            setattr(self, name, vectorize(getattr(self, name)))

    def bar(self, x): pass

which works fine but it doesn't seem like it should be necessary to do
it in the initialization of every instance.


More information about the SciPy-user mailing list