But what if you urgently need to buy 57 short swords?

More seriously, they could make so that a merchant never has more than four of any weapon or armour item.
Also it's not like there is an over abundance of merchants in the game so you can spread the load a bit.

Originally Posted by JandK
I haven't tried, but I wonder if you could put all the stuff you're selling in a pouch and then just sell the pouch?
.

That may unclutter the inventory screen but the items would still have to catalogued by the game so the performance hit would probably still be there.