We present a high-pressure optical and infrared spectroscopy study on the mechanical stability of single-walled carbon nanotubes (SWCNTs) filled with C-60 and C-70 fullerene molecules (C-60- and C-70-peapods), double-walled carbon nanotubes (DWCNTs) derived from the C-60- and C-70-peapods (DWCNTs/C-60 and DWCNTs/C-70), and iodine-filled SWCNTs (I-SWCNTs). High-resolution transmission electron microscopy, Raman, and optical spectroscopy were used to characterize all prepared samples. For the C-60- and C-70-peapods, we find an anomaly in the pressure-induced shifts of the optical transitions at the critical pressures P-c1 approximate to 6.5 and 7.0 GPa, respectively, compared to P-c1 approximate to 3 GPa in the case of empty SWCNTs. The shift of the anomaly to higher pressure signals the stabilization of the nanotubes by the C-60 and C-70 filling. The value of P-c1 is in good agreement with theoretical predictions of the pressure-induced deformation for highly filled peapods with similar average diameter. In comparison to SWCNTs, the pressure-induced red shifts of the optical transitions in DWCNTs/C-60 are extremely small below similar to 10 GPa, demonstrating the enhanced mechanical stability due to the inner tube. The anomaly at the critical pressure P-d approximate to 12 GPa in DWCNTs/C-60 signals the onset of the pressure-induced deformation of the tubular cross sections or the collapse of the DWCNTs. For the DWCNTs/C70, the anomaly in the pressure-induced shift is lowered to P-d approximate to 9 GPa compared to 12 GPa in the case of DWCNTs/C-60. This behavior signals that the stabilization of the outer tube by the inner tube in DWCNTs/C-70 is lower compared to the DWCNTs/C-60. Interestingly, the iodine filling shows a stabilization for the outer tubes up to 10 GPa in contrast with the previously published Raman results. For all samples, except I-SWCNTs, the low energy absorbance decreases rapidly with increasing pressure, suggesting the destruction of the SWCNT electronic band structure and hence an increasing carrier localization. In the I-SWCNTs the pressure-induced free carriers localization is partially compensated by the metallization of the iodine chains under pressure.