# Set Attribute¶
y is a list and atom
- an item from the list
ywith the corresponding attribute set
- the null symbol
ywith all attributes removed
q)`s#1 2 3 `s#1 2 3 q)`#`s#1 2 3 1 2 3
Setting or unsetting an attribute other than
upg) causes a copy of the object to be made.
s attribute on a list which is already sorted will not cause a copy to be made, and hence will affect the original list in-place.
s attribute on a dictionary or table, where the key is already in sorted order, in order to obtain a step-function, causes the
s attribute to be set in place for the key but copies the outer object.
g are preserved on append in memory, if possible.
s is preserved on append to disk.
q)t:([1 2 4]y:7 8 9);`s#t;attr each (t;key t) ``s
u is for unique lists – where all items are distinct.
Grouped and parted
g are useful for lists in memory with a lot of repetition.
If the data can be sorted such that
p can be applied, the
p attribute effects better speedups than
g, both on disk and in memory.
g attribute implies an entry’s data may be dispersed – and possibly slow to retrieve from disk.
Some q functions use attributes to work faster:
- Where-clauses in
exectemplates run faster with
distinct, Find and
in(if the right argument has an attribute)
g attribute is presently unsuitable for cycling through a small window of a domain, due to the retention of keys backing the attribute.
q)v:`g#1#0 q)do[1000000;v+:1]; q)0N!.Q.w`used; v:`g#`#v; .Q.w`used 74275344 332368
Applying an attribute to compressed data on disk decompresses it.