Important code has a way of starting out unimportant.
This is true, but including code like this should make it easier to know you should rewrite if you are going to use it in something important. I have been bitten more often by quick hack code that looks OK on the surface than code that is full of clever code like this.
I could _maybe_ see this code ending up in production code where performance optimization matters (if it actually fixes a performance issue). But if you did that you had better put a comment next to it clearly explaining why you had to do that for optimization purposes and how it works.