On Sun, Jan 16, 2022 at 9:28 PM Guido van Rossum <guido@python.org> wrote:
Does the optimization for //10 actually help in the real world? [...]
Yep, I don't know. If 10 is *not* the most common small divisor in real world code, it must at least rank in the top five. I might hazard a guess that division by 2 would be more common, but I've no idea how one would go about establishing that. The reason that the divisor of 10 is turning up from the PGO isn't a particularly convincing one - it looks as though it's a result of our testing the builtin int-to-decimal-string conversion by comparing with an obviously-correct repeated-division-by-10 algorithm. Then again I'm not sure what's *lost* even if this optimization is
pointless -- surely it doesn't slow other divisions down enough to be measurable.
Agreed. That at least is testable. I can run some timings (but not tonight). -- Mark