Is there an easy way to add a record/row to a numpy recarray without creating a new recarray? Let’s say I have a recarray that takes 1Gb in memory, I want to be able to add a row to it without having python take up 2Gb of memory temporarily.
Share
You can call
yourrecarray.resizewith a shape which has one more row, then assign to that new row. Of course.numpymight still have to allocate completely new memory if it just doesn’t have room to grow the array in-place, but at least you stand a chance!-)Since an example was requested, here comes, modified off the canonical example list…: