[Numpy-discussion] recarrays and lists of lists
Sun Sep 11 14:44:29 CDT 2011
On Sep 11, 2011, at 2:58 AM, Robert Kern wrote:
> On Sun, Sep 11, 2011 at 00:30, Travis Vaught <firstname.lastname@example.org> wrote:
>> Is there a particular reason why a list of lists can't be passed in to create a recarray given a particular dtype?
>> A list of tuples works fine. I keep getting bitten by this and was thinking it should be an easy check/convert for an allowance for a row to be a list _or_ a tuple?
> As a rule, tuples are considered "scalar" records and lists are
> recursed upon. This rule helps numpy.array() figure out which
> sequences are records and which are other sequences to be recursed
> upon; i.e. which sequences create another dimension and which are the
> atomic elements. Otherwise, it has to make some guesses and do some
> intelligent backtracking. It's not that intelligent.
> Robert Kern
Thanks for the explanation. It makes a bit of sense -- at least to answer the question of what is being traded off here. Looks like simplicity and performance, perhaps, is being chosen over my convenience.
More information about the NumPy-Discussion