unsafe_store
on anything that contains a reference also deletes that object from the GC knowledge graph (because it is “unsafe”), so you cannot use that on anything that contains a reference (without allocating a secondary “shadow” array that contains a “safe” copy of each operation on the objects–but then you might as well use the secondary copy as the only copy)
Thank you to everyone who contributed to this thread. While I still believe it is possible to construct such a buffer datatype safely, it may require further language integration and I no longer believe it is simple or straightforward enough to be worth implementing for my particular use case.
Additionally, based on @cjdoris’s comments I realize now that similar
has the further advantage of being able to preserve optimizations in memory management of user-defined AbstractArrays (e.g. UInt12Arrays) which a plain buffer has no hope of doing.
3 Likes