[Numpy-discussion] Selection of only a certain number of fields
Sun Feb 8 10:09:02 CST 2009
Francesc Alted <faltet <at> pytables.org> writes:
> > What are some common use cases for this feature?
> > I use structured arrays quite a lot, but I haven't found myself
> > wanting something like this. If I do need a subset of a structured
> > array generally I use something like
> > [rec[n] for n in 'name age gender'.split()]
> Good point. However, there are still some very valid reasons for having
> an idiom like:
> newarr = arr[['name', 'age']]
> returning a record array.
> The first one (and most important IMO), is that newarr continues to be
> an structured array (BTW, when changed this name from the original
> record array?), and you can use all the features of these beasts with
> it. Other reason (albeit a bit secondary) is that its data buffer can
> be shared through the array interface with other applications, or plain
> C code, in a relatively straightforward way. However, if newarr
> becomes a list (or dictionary), this is simply not possible.
That's not a sample use case ;)
One of the things I love about Python is that it has a small core set of
features and tries to avoid having many ways to do the same thing. This makes
it extremely easy to learn. With every new feature, numpy gets a little bit
harder to learn, there's more to document and the code base gets larger and so
harder to maintain. In those senses, whenever you add a new function/feature to
numpy, it gets a little bit worse.
So I think it would be nice to have some concrete examples of what the new
feature will be useful for, just to show how it outweighs those negatives. As a
bonus, they'd provide nice examples to put in the documentation :).
PS. Thanks for your work on pytables! I've used it quite a bit, mostly for
reading hdf5 files.
More information about the Numpy-discussion