Emerging applications including semantic information processing impose priorities on the possible realizations of information sources, so that not all source sequences are important. This paper proposes an initial framework for optimal lossless compression of subsets of the output of a discrete memoryless source (DMS). It turns out that, the optimal source code may not index the conventional source-typical sequences, but rather index certain subset-typical sequences determined by the source statistics as well as the subset structure. Building upon an achievability and a strong converse, an analytic expression is given, based on the Shannon entropy, relative entropy, and subset entropy, which identifies such subset-typical sequences for a broad class of subsets of a DMS. Interestingly, one often achieves a gain in the fundamental limit, in that the optimal compression rate for the subset can be strictly smaller than the source entropy, although this is not always the case.