.22 rimfire free pistols, such as the single shot ones shown here:
free pistol - Google Search
will shoot about 1/4 inch at 50 meters, same as .22 caliber free rifles. By "free," I mean they are virtually free of restrictions. They have those longer barrels to make them front heavy so they can be held better and easier to align the sights.
High Standard and Smith & Wesson both made target pistols with shorter barrels that shoot almost as good. Ruger semiautos were also rebuilt and did very well in competition.
For rifles, .22 rimfire target rifles originally had 26 to 28 inch barrels so their front sight woud be far enough away. But it takes a long time for those slow bullets to leave the barrel after the round fires. Rimfire compeition is a holding game; you have to hold still while the bullet goes down the barrel. It takes 3 times as long for a rimfire bullet to clear the muzzle than high power rifles. Anschutz finally did something about this and made their top target rifles with 19 inch barrels with a "bloop tube" on the muzzle to extend the front sight an exta 6 to 8 inches. That bloop tube's about 3/4 inch inside diameter.
For a rifle, a 19 to 20 inch barrels is probably optimal for accuracy as well as holding when they have a scope on them.