Account Balance and Bitcoin-QT I'm attempting to clarify a few things in my mind. The wallet.dat file contains (amongst other things) my transaction history alongside the private keys associated with each address in use in the wallet. 

Let's say I'm one of those open source weirdos and I use PyWallet to open the wallet.dat and pull the private keys and addresses out of my wallet. Now say my goal is to create a new wallet (called it Cwallet). Now CWallet can sign transactions for my bitcoins from bitcoin-qt, but how would it actually get an account balance?

Does CWallet have to search through the entire blockchain and find my address and then follow it to the most current block? Or is there an optimized way of determining the balance?
If you used some python scripts to generate a new wallet file and want to use it with bitcoind or bitcoin-qt, you will probably need to rescan the whole blockchain via running bitcoind -rescan (it may take much time).

After that you can use bitcoind listaccounts to get balances of all your accounts (or bitcoind getbalance to get the total amount).

Not sure if it answers your question though, since not sure what you mean under 'account' and 'CWallet'.