in reply to Re^3: Need for (XS) speed
in thread Need for (XS) speed

Using SvPVX instead of SvPVbyte makes needless assumptions.

I'm sorry to have to start this all over again, but you are wrong. And here is why you are wrong.

The only thing that it makes sense to pass to a routine expecting a scalar containing a string of packed integers, is exactly that.

The only useful behaviour of those, is the trap. Because it tells me that I haven't passed a packed scalar. Immediately, and unambiguously.

If however, I call SvPVbyte, it won't prevent me from getting a trap if I pass an SV without a PV. But it will turn all the other cases into a piece of memory that there will be no way to discern was not a packed scalar of integers until I start getting garbage results.

And it could take me a long time to trace the source of that garbage back to the error.

The only assumption using SvPVX makes, is that I have passed a properly packed array. And if I haven't, it traps immediately, which tells me exactly where the problem lies.

In other words, the only assumption it makes, is that I know what I'm doing-- and immediately tells me, in no uncertain terms, if I do not.

And that's an invaluable behaviour in any piece of software!

I do not expect you to agree, nor want you to respond.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"

Replies are listed 'Best First'.
Re^5: Need for (XS) speed
by ikegami (Patriarch) on Mar 05, 2010 at 16:24 UTC
    You sure put a lot of effort avoiding what surely has an O(1) cost of microseconds before a costly O(N) operation (according to the OP).

      It's not about performance. It's about reliability. The trap is infinitely more valuable than no trap. It really surprises me that you can't allow yourself to understand that.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        I hadn't read your post. I got tired of answering your questions going in 10 different directions. I have now.

        I'd use SvPOK over segfaults as an error check.