I myself would wonder just indeed what would be the ideal caliber to carry if one was in space and needed a gun for protection, eventually the Pirates of Ganymede will try to board christian immigrant ships fleeing from Islam Earth so one could fantasize a wee bit.
Since its a vacuum velocity will not bleed off, you will need a penetrating type of projectile, a tracer would be ideal as when it makes contact with oxygen in you bad persons space suit it creates a mini thermobaric detonation and you now have bacon bits in a space suit.
However one cannot have just a singular pistol for space, no what we need is a smart gun, it should be talked to like in Lost in Space, it will be encoded to your personal DNA.
It should be able to instantly analyze the atmo and either send a super fast flechette such as in space, or a frangible low velocity round that won’t ventilate that goodly cocktail breathing soup of BO, WD40 and yesterdays spaghetti sauce from your tin can in space.
Or better yet a bullet so smart it will actually have a mini thruster motor so that when you get a million Moslems on the moon shooting into space with their AK7400 they won’t be turning a nearby space station into a colander.
In summary, in space you really should have a bullet that will stop either by timed flight, distance or destruction.
I remember as a kid seeing those magic bullet cartoons. They would not dumbly pierce anything suitably soft in their path. Instead they would screech to a halt, toss a net over their target, or deploy a little mallet that conks the target over the head, or something equally cute. I tried to figure out in my little-tyke head how such a gimmicked projectile might be made to work. I figured something like air resistance acting on a deployment mechanism such that the gimmick deploys at the desired distance from the gun, and even tried to build a model out of paper and kiddie wooden blocks, but heck if I understood the physics.