Closed jpivarski closed 2 years ago
@jpivarski - it looks like it's implemented in v2:
>>> import numba as nb
>>> import awkward._v2 as ak
>>> import awkward._v2._connect.numba.arrayview
>>> import awkward._v2._connect.numba.builder
>>> def add_a_string(builder, string):
... builder.string(string)
... return builder
...
>>> builder = add_a_string(ak.ArrayBuilder(), "hello")
>>> builder.snapshot()
<Array ['hello'] type='1 * string'>
Oh, that's nice! I must have done that while porting from v1 to v2 and forgot to close this issue. I guess this wasn't needed. Are all of v2 ArrayBuilder's Python methods available in Numba? (Excluding the ones that require a context manager, since that hasn't been implemented in Numba yet.) If so, then you can close this issue.
The other starter issue, #1420, has not been implemented in v2. Looking at it now, it gets a little more into the internals of Numba, since you have to distinguish between Numba's string type and Numba's literal string type, but that's still not a very deep rabbithole.
Done in #1677.
I'm astonished: it's weird that I would just forget that. But it does explain why
append
isn't overloaded to cover it. Probably the feature was added later and the ArrayBuilder-in-Numba implementation is just behind the times?Indeed: it's missing. Also, I don't see it in either the v1 or the v2 implementation.
This should be a separate issue: ArrayBuilder-in-Numba is missing
string
andbytestring
, and possibly other new methods (complex
?datetime
?). Fortunately, we know what the interface is supposed to be: it's supposed to be the same as outside of Numba, the ArrayBuilder Python interface.(BTW: ArrayBuilder-in-Numba's lack of context managers
list
,record
, andtuple
is known because it's waiting on context managers as a feature from Numba, but it sounds like this will be implemented soon, and Awkward Array will be a first use-case.)Originally posted by @jpivarski in https://github.com/scikit-hep/awkward-1.0/issues/1420#issuecomment-1105476531