If a predator is going to attack you, it's for one of four reasons. One, you're vulnerable looking, maybe injured or a young child. Two, you stumbled upon a mother with its young, and your proximity to its young depends on whether or not it will attack you. In this case if it decides to attack you, one of you is not walking away from this situation. Third, its mating season and you stumble upon a male who thinks or knows that a female(his female) is nearby and you could threaten his chance to mate in some way. Fourth, you stumbled upon something that was in the act of feeding and it doesn't want competition.
If a mountain lion sees you as prey, they're not going to attack you unless they're absolutely sure you have NO idea they're stalking you. They will then jump down from a high location behind you, run a short burst, and grab the back of your neck, or they'll lightly jog up to you until they're very close, then charge you.
I was fishing in the dark at a lake in Colorado, and I saw something that sort of looked like a german shepard from a long distance walking down the boat ramp. It went under a tree and clawed at the ground, something a dog wouldn't do as agressively as this animal did, and when I got a better look I realized it was a mountain lion. It had no idea I was there because I stayed quiet. It started walking toward me and I was cornered beside my ability to jump in the water and start swimming. I stood up with my flashlight in hand when the cat was about 20 ft away. It stopped in its tracks. I turned on the flashlight, shined it in its eyes, and swayed the light left and right in its eyes somewhat slowly. It paused while I did this, not sure what to make of the situation, then after what seemed like 30 seconds it turned and briskly walked the other direction, stopping and turning every few steps to make sure I was not giving chase. It went back up the boat ramp and I didn't see it again. The important thing really is watch your back and never enter an area if you can't run in at least three different directions from that area, because if you turn a corner and happen upon something that is now cornered by you, it's gonna attack. You need to make sure anything you happen upon has more than one way to slowly back away from you, or you have the same option.
Edit: I would trust a high-capacity 40 SW against mountain lions and black bears, and I do have one, a Glock 23, partially for this purpose, not because it would kill the animal but becase it would be sufficient in at least three of those four situations to scare the animal away. If the situation of me happening upon something with its young occurs, I'm gonna unload everything I got at that animal if it charges me, and I consider this situation a coin-toss because of how tough bears are and how small and quick mountain lions are. Better than nothing though, and with my experience in my local environment I shouldn't run across a predator with its young anyway.