A formal way to say "I don't want to sound too cocky..."

Solution 1:

To say the same thing, you can say

I hope it won't be considered presumptuous to say this, but... or

I don't want to sound presumptuous, but...

Synonyms that you can substitute here for presumptuous are
impertinent, overconfident, arrogant, bold, insolent, impudent, and of course the less formal sounding "cocky".

To sound deferential, but not say precisely the same thing, you could say

When I compared the code performance, I was surprised to see the degree of improvement my code achieved.

Wording it either way would leave you open to discussing the possibility that your code or your testing may be flawed, while making your point about its apparent improvement.

Solution 2:

While we often think that our idea/viewpoint/product is far superior to others we encounter, the needs of the creator or other users may be divergent from our own, or what we think theirs are. We may view precision as the primary criterion, while they think ease of use is paramount. And they may be the deciders.

One approach to acknowledge that another viewpoint may be more controlling is

I may be wrong [mistaken/off-base/not fully aware of all the issues], but it seems that my approach may get us closer to a solution.

Even if you are dead certain that their method sucks compared to your elegant solution, you have a better shot at being heard if you suggest that you may not be correct.

Solution 3:

Don't just assert; support the assertion.

"Testing with the Arcane Blivit dataset indicates that this implementation improves performance of the Deeble function by 20%, which improves our overall performance on that dataset by 3%. I'd be glad to repeat the experiment with other datasets to make sure this isn't an atypical result." Or explain why the new version is easier to maintain, or handles necessary cases that weren't previously addressed, or whatever else its advantage is. If you can't explain in a few sentences why yours is better, you don't understand it well enough to make the assertion in the first place.

Then, if you're told no, politely try to understand why the answer is no. Don't argue -- listen more than you speak.

In other words: If you don't want to come across as arrogant, don't be arrogant.