A novel inorganic–organic photoluminescent (PL) and nonlinear optical (NLO) poly(3-dodecylthiophene)–CdS (P3DDT–CdS) with different molar ratios of CdS to P3DDT were synthesized via a oxidation coupling polymerization reaction and chemically hybridized approach, respectively. The P3DDT matrix possesses a highest-occupied molecular orbital value of about −5.87eV determined from cyclic voltammetry. The third-order nonlinear optical susceptibility of P3DDT–CdS (−4.41×10 −12 esu) is higher than that of P3DDT and CdS, respectively. The coherent oscillation of the conduction band electrons in the nanocomposites is responsible for excellent NLO properties of P3DDT–CdS. The CdS particles as electron transport layer and photosensitizers had a nanoscale size in P3DDT adopting transmission electron microscopy. PL results show that, the electron-hole recombination occurred in the P3DDT is dominant, due to the valence band offset of P3DDT–CdS is higher than conduction band offset. The figures of merit of P3DDT and P3DDT–CdS are of −4.25 and −0.99, respectively. So, the P3DDT–CdS shows a potential application in the all-optical switching materials.