Couldn't tell you for certain. Probably some combination of genetics and intense training, with previous periods of long sustained critical work.
Often I find I compare whatever my current situation I'm in, with previous tough situations I've dealt with, and know that if I made it through those, then my current situation is tractable.
On multiple occasions in a previous life I've worked multiple 24-36 straight hours doing intense cognitive and physically intensive work for multiple crises in Korea, Iraq and other wartime places. So that's a good benchmark to compare to.
Right, everything else is trivial in comparison. As a result, working an extra few hours on some Python is just a great thing to be able to get paid for.
The secret according to my business professor who was an electrical engineer, a sniper in the military, and started a multimillion dollar PE firm, and sleeps <6 hours every night: eat more.