In general topology, a subset of a topological space is **perfect** if it is closed and has no isolated points. Equivalently: the set is perfect if , where denotes the set of all limit points of , also known as the derived set of .

In a perfect set, every point can be approximated arbitrarily well by other points from the set: given any point of and any neighborhood of the point, there is another point of that lies within the neighborhood. Furthermore, any point of the space that can be so approximated by points of belongs to .

Note that the term *perfect space* is also used, incompatibly, to refer to other properties of a topological space, such as being a G_{δ} space. As another possible source of confusion, also note that having the perfect set property is not the same as being a perfect set.

Examples of perfect subsets of the real line are the empty set, all closed intervals, the real line itself, and the Cantor set. The latter is noteworthy in that it is totally disconnected.

Whether a set is perfect or not (and whether it is closed or not) depends on the surrounding space. For instance, the set is perfect as a subset of the space but not perfect as a subset of the space .

Every topological space can be written in a unique way as the disjoint union of a perfect set and a scattered set.^{[1]}^{[2]}

Cantor proved that every closed subset of the real line can be uniquely written as the disjoint union of a perfect set and a countable set. This is also true more generally for all closed subsets of Polish spaces, in which case the theorem is known as the Cantor–Bendixson theorem.

Cantor also showed that every non-empty perfect subset of the real line has cardinality , the cardinality of the continuum. These results are extended in descriptive set theory as follows:

- If
*X*is a complete metric space with no isolated points, then the Cantor space 2^{ω}can be continuously embedded into*X*. Thus*X*has cardinality at least . If*X*is a separable, complete metric space with no isolated points, the cardinality of*X*is exactly . - If
*X*is a locally compact Hausdorff space with no isolated points, there is an injective function (not necessarily continuous) from Cantor space to*X*, and so*X*has cardinality at least .