If i had a choice to buy an 07 335 or an 06 E46 M3 I would still buy the 335. They go for about the same price, and this is more justifiable over a new 335.
My point is not teh suxorz, because if you buy both of them used, you cannot tell me the M will be as good tuned with the same kind of Money (IE sub 5k as Anuk stated)
Even in Stock form the 335 will be just as quick. Plus newer body style and have some warranty left.
Now lets flip it like this, Immagine buying a used 335 for 40K and put just 6K in Mods into the car. It will be killer and the OP will have some $$ left over.