The effect of gas compression on spontaneous flame acceleration in tubes in deflagration-todetonation transition is studied theoretically. The theory assumes weak compressibility through expansion in small Mach number. The results show that when Mach number is negligible during the initial stage of propagation, the flame front accelerates exponentially propagating from the closed end of the tube. Eventually, when the flame velocity with respect to the tube walls becomes comparable to the sound speed, the flame-generated compression waves actively modify the flame dynamics. In particular gas compression moderates the acceleration process by affecting the flame shape and velocity as well as the flow driven by the flame. The theory explains recent results on flame acceleration obtained in experiments and direct numerical simulations.