A quick recap (my personal preference would be the G40).
G40---longer barrel/slide, heavier, Modular Optics System.
1. The longer sight radius might make it more accurate in your hands. I realize the longer barrel does NOT make the gun more accurate but the longer sight radius might aid in aiming.
2. The longer barrel will allow you to get higher velocities than the shorter barrel.
3. Heavier weight and longer barrel/slide will absorb recoil and reduce muzzle flip. Probably get you quicker and more accurate subsequent shots.
G20---handier pistol
For all our pontificating about all the points that have been raised it might just come down to can you stand carrying the longer slide/barrel of the G40? I could easily see where the irritation factor of the longer, heavier G40 would outweigh every positive feature of the gun.
Guess it’s up to you to decide. (Gosh Captain Obvious, thanks for the insight!!!)
For what it’s worth you could have the G20 slide modified to take an optical sight if that is a big factor, and I would give some consideration to agtman’s opinion about the trigger, although that too can be modified for a price.