40g is a tad big except for a really large female. The bigger the tank, the harder to get temps and humidity stable.
Overall, you don't want a tank to be any taller than 18", preferably 12". And remember that these snakes LIKE tight spaces that make them feel secure. You don't want too much room or they'll freak out.