I think the key insight of #2648 (optimizing uniqueN for logical input) was: we know in advance the output of uniqueN can only take on a small number of values (namely, NA, TRUE, or FALSE).
This logic should extend easily to factor columns as well, where we know the maximum possible uniqueN(factor_col) is length(levels(factor_col)) (+1 if !na.rm).
This is probably related to #2458, as well as #1120.
I think the key insight of #2648 (optimizing
uniqueNfor logical input) was: we know in advance the output ofuniqueNcan only take on a small number of values (namely,NA,TRUE, orFALSE).This logic should extend easily to
factorcolumns as well, where we know the maximum possibleuniqueN(factor_col)islength(levels(factor_col))(+1 if!na.rm).This is probably related to #2458, as well as #1120.