[SciPy-user] NumPy arrays of Python objects (it was Re: How to start with SciPy and NumPy)
Mon Jan 26 11:18:58 CST 2009
A Monday 26 January 2009, Vicent escrigué:
> On Mon, Jan 26, 2009 at 12:45, David Cournapeau <
> firstname.lastname@example.org> wrote:
> > Vicent wrote:
> > > (2) Just to be sure: An array can be assigned to a property of an
> > > object, can't it?
> > A numpy array is a 'full' python object, thus can be used in the
> > same cases as a python object.
> Sorry I meant "working with classes" vs "working with structures or
> I know that everything in Python is an object, but I was thinking of
> building my own structures for storing information by using
> "classes", in a OOP context.
> There I realize that maybe I have to forget defining "classes" and
> just use NumPy objects, for those heavy/intensive search and/or
> computing tasks in my code.
Or just implement a bridge between your "classes" and NumPy objects.
There are many possibilities, but IMO you should try first some of the
most easy-to-work possibilities that you can figure out and then add
complexity or NumPy objects in case you need them. It is worth to note
that, although in many cases the fact of working with NumPy objects
eases the life of the programmer, this should be not the case for
everyone. As always, your mileage may vary.
> [ Again, asking myself...: Do I miss something? I mean, actually, a
> NumPy array has properties/attributes and methods... So, maybe using
> objects from NumPy doesn't mean forget object oriented programming. I
> think I was a bit confused about it... ]
Yeah. Many programs that use NumPy intensively are perfect examples of
OOP. NumPy and OOP are not mutually exclusive in any way.
More information about the SciPy-user