Why does pay to pubkey hash contain OP_CHECKSIG at the end instead of beginning? According to the bitcoin wiki, the most common form of transaction (pay-to-pubkey-hash) looks like this:

scriptPubKey: OP_DUP OP_HASH160 &lt;pubKeyHash&gt; OP_EQUALVERIFY OP_CHECKSIG
scriptSig: &lt;sig&gt; &lt;pubKey&gt;


I am curious why OP_CHECKSIG comes at the end. Couldn't we check the signature even before doing the hash?

More precisely, couldn't it instead do:

scriptPubKey: OP_CHECKSIGVERIFY OP_DUP OP_HASH160 &lt;pubKeyHash&gt; OP_EQUAL
scriptSig: &lt;pubKey&gt; &lt;sig&gt;


This way you don't have to go through all the hashing if the pubkey and sig don't match to begin with. 

I'm sure there's a good reason for this or i'm completely misunderstanding something, please enlighten me. Thank you!
Couldn't we check the signature even before doing the hash?


We certainly could, but that would be silly. The hash is about 1000x faster than checking a signature. Doing the signature check when the hash fails would be a waste of time


  More precisely, couldn't it instead do:
  
  scriptPubKey: OP_CHECKSIGVERIFY OP_DUP OP_HASH160  OP_EQUAL


No, that certainly wouldn't work. The OP_CHECKSIGVERIFY would remove the public key from the stack, so there is nothing to compare it with. The OP_DUP would always fail, as there is nothing to duplicate anymore.