in reply to Unexpected: unpack slower than several substr's. Why?

My educated guess would be that since unpack is more general purpose, and since it has to parse the format specification(s) before it knows what to do, that a small set like 15 would be faster with substr calls. substr is simple and specific enough that many of us can write it in our head. Probably not so with unpack.

You're doing the right thing by using benchmarks to make your decisions. Sometimes what seems obvious isn't when it comes to performance.

  • Comment on Re: Unexpected: unpack slower than several substr's. Why?