I've invested some time and money in looking for the 'ideal' compact/subcompact .40 S&W pistol for use as an off-duty (and now retirement) weapon.
I presently own a 4013TSW, 4040PD, G27 and a M&P 40c.
Although Glock considers their G27 a subcompact in their model lineup and S&W considers their M&P 40c to be a compact, as you probably noticed when holding them, they're pretty similar in overall size.
Where they differ is some features, ergonomics and the experience of recoil management and felt recoil. Although each is still a .40 and will have some snap and muzzle rise, the M&P 40c offers me much better controllability and it makes it easier to shoot more rounds during range sessions. Although I alternated shooting the guns, the last time I took both my M&P 40c and G27 to the range I found that shooting 100 rounds through the G27 was about like shooting 300+ rounds through the M&P 40c.
It would probably really help if you could find a range that rented both so you could try 100 rounds of ammunition comparable to whatever you expected to shoot and carry through each. Personally, after trying all 3 grips in the M&P 40c I found I did my best shooting with the medium grips, even though the large grips 'felt better' in hand when I wasn't actually shooting the gun. The medium grips did better during live fire. The small grips were actually too small.
The G27 has the stubby and chunky Glock subcompact grip, and you may have to adapt to it.
FWIW, I also own a G26, and if I were only going to keep one Glock, it would be the G26.
I also like the 99 series pistol line (P99/SW99), but as with the Glock line, I tend to like it best chambered in 9mm. I own a SW9940 standard size and even carried an issued one for a few years, and have fired many thousands of rounds through 99's chambered in .40, so it's not like I haven't given them a fair shake. I came close to picking up a SW9940c several years ago, but trying a couple of them that belonged to other guys convinced me to buy the SW999c, instead. It's become a favorite among my smallish 9's. I just don't care for the .40 version.
I tend not to care for the XD and Kahr series, as well, after having tried several of them, but other folks seem to like them.
I think the M&P 40c is going to give the G27 some stiff competition from this point onward when it comes to smaller .40's, and understandably so.
Try to test-fire them and decide which might better serve your preference.