In-place attribute removal

https://learninghub.kx.com/forums/topic/in-place-attribute-removal

Is there any way to do this? # looks to always be creating a copy of the original list for g/u, whether it's applied on a list reference or value. I wrote a C function to set the list object's u member (x->u) to 0, and from within q called this function and followed it up with re-applying the attribute (g#) and this combination seems to clear the attribute without making a copy and also removes the references to the previous attribute data, allowing it to be garbage collected by .Q.gc. Is there another way? Thanks in advance.

According to the docs at Set Attribute | Reference | kdb+ and q documentation - Kdb+ and q documentation (kx.com) :

Setting or unsetting an attribute other than sorted causes a copy of the object to be made.

 

Using a C function as a workaround might work but it might also break in a future version when kdb+ internals change.