This paper presents a new algorithm for reactive-power optimization of large-scale power systems involving both discrete and continuous variables. This algorithm realizes successive discretization of the discrete control variables in the optimization process by incorporating a penalty function into the nonlinear primal-dual interior-point algorithm. The principle of handling these discrete variables by the penalty function, the timing of introducing the penalty function during iterations, and the setting of penalty factors are discussed in detail. To solve the high-dimension linear correction equation speedily and efficiently in each iteration, a novel data structure rearrangement is proposed. Compared with the existing data structures, it can effectively reduce the number of nonzero fill-in elements and does not give rise to difficulty in triangular factorization. The numerical results of test systems that range in size from 14 to 538 buses have shown that the proposed method can give nearly optimum solutions, has good convergence, and is suitable for large-scale system applications.