I am trying to figure out how big could a contract be? Is it possible to have 10k functions? One million? More?
Is there any restriction on the function's body size?
Does a bigger contract need more gas to be deployed?
Is a bigger contract slower than a smaller one?
Best Answer
Solidity contracts are compiled to EVM bytecode. Contract bytecode costs 200 gas per byte of bytecode, and since block gas limit is 8 million right now, you could theoretically get a ~40,000 (a little less since there's extra for deployment/tx data) byte contract deployed. It's unlikely that you'd be able to create a contract this size though since blocks don't usually have that much extra space already. Regarding execution speed, this is totally dependent on your implementation.
Edit: As pointed out be @Ismael, there's actually a 32kb limit per transaction as explained here. That page also says there's also a 24576 byte limit for contract size, so I stand corrected! The EIP for the contract byte limit can be found here.
Edit2: If you're looking for a formal explanation for the contract size limit, check out definition 97 of the yellow paper:
That is, the output size of the final body code must not be bigger than 24576 bytes.