Considering its relatively low price, the EF 40mm f/2.8 STM was a solid performer on our DxOMark Camera Lens Ratings. [...] it rates among the top seven standard prime lenses (with a focal range between 35mm and 85mm) achieving an overall DxOMark Score of 26.
Strengths of the Canon EF 40mm f/2.8 STM include resolution [...] Additionally, our sharpness measurements and field maps [...] indicated that the lens delivered relatively consistent edge-to-edge sharpness from f/2.8 to f/11.
Other strengths include its low geometric distortion and well-controlled chromatic aberration as indicated by its low Chromatic Aberration score of 10µm.
The one weakness of the Canon EF 40mm f/2.8 STM was the strong vignetting evident at the widest apertures. You can see from the vignetting field maps below that at f/2.8, there is heavy shading across 2/3 of the field.
The Canon EF 40mm f/2.8 STM actually has price tag of $149. A bargain for a lens that has such a good perfomance (click on shop name): Amazon, B&H, Adorama, Canon USA, J&R, Digitalrev, eBay, rent it at Borrow Lenses.
The 40mm pancake performs slightly better than the much pricier Canon EF 50mm f/1.4 USM(price & specs), and the cheaper EF 50mm f/1.8. As you can see, all three lenses have very good sharpness figures.