apache / arrow-nanoarrow

Helpers for Arrow C Data & Arrow C Stream interfaces
https://arrow.apache.org/nanoarrow
Apache License 2.0
151 stars 34 forks source link

python: consider adding back a na.array(..) constructor #434

Closed jorisvandenbossche closed 2 months ago

jorisvandenbossche commented 2 months ago

While writing the example for our tutorial, the usage of na.Array(..) stood a bit out. There is of course nothing "wrong" with it, but it does feel inconsistent with how many other libraries provide their general purpose constructor (eg pyarrow.array(), numpy.array(), torch.tensor(), etc), and also somewhat internally with most or our other constructors (eg na.c_array() and not na.CArray(), and several other such cases)

So the suggestion to consider adding again a nanoarrow.array(..) -> Array constructor function (I think at some point in the Array PR it did exist?)

paleolimbot commented 2 months ago

I forget exactly which review suggested I drop it (perhaps from @danepitkin ?), but I don't have strong feelings either way. Right now it gives a very bad error message (below), so I'm inclined to add it back (but perhaps keeping the documentation with the Array constructor?).

import nanoarrow as na
na.array([1, 2, 3], na.int32())
#> TypeError: 'module' object is not callable