Re: [Numpy-discussion] object dtype questions

2009-09-06 Thread Ernest Adrogué
5/09/09 @ 11:22 (-0600), thus spake Mark Wendell: For example: Say that C is a simple python class with a couple attributes and methods. a = np.empty( (5,5), dtype=object) for i in range(5): for j in range(5): a[i,j] = C(var1,var2) First question: is there a quicker

Re: [Numpy-discussion] object dtype questions

2009-09-06 Thread Sturla Molden
Mark Wendell skrev: for i in range(5): for j in range(5): a[i,j].myMethod(var3,var4) print a[i,j].attribute1 Again, is there a quicker way than above to call myMethod or access attribute1 One option is to look up the name of the method unbound, and then use built-in

Re: [Numpy-discussion] object dtype questions

2009-09-06 Thread Alan G Isaac
On 9/6/2009 8:33 AM, Sturla Molden wrote: map( cls.myMethod, a ) is similar to: [aa.myMethod() for aa in a] http://article.gmane.org/gmane.comp.python.general/630847 fwiw, Alan Isaac ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org

Re: [Numpy-discussion] object dtype questions

2009-09-06 Thread Sturla Molden
Alan G Isaac skrev: http://article.gmane.org/gmane.comp.python.general/630847 Yes, but here you still have to look up the name 'f' from locals in each iteration. map is written in C, once it has as PyObject* to the callable it does not need to look up the name anymore. The dictionary

[Numpy-discussion] object dtype questions

2009-09-05 Thread Mark Wendell
When I create an array with a dtype=object, and instance a custom python class to each array member, have I foregone any opportunity to call methods or get/set attributes on those instances with any of numpy's 'group' operations? In other words, it seems like once I've got a custom object as an