First of all you need to get your dependencies right. That mostly depend on what you have already installed previously. So for a vanilla fresh Raspbian (jessie), you will (approximately) need to make sure you have these:
sudo apt-get install build-essential libc6-dev
sudo apt-get install libncurses5-dev libncursesw5-dev libreadline6-dev
sudo apt-get install libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev
sudo apt-get install libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev
The rest is simple. First download and extract...
cd $HOME
wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
tar -zxvf Python-3.5.2.tgz
...and then compile with:
cd Python-3.5.2
./configure # 3 min 13 s
# We have 4 processors, so let's use 4 threads
make -j4 # 8 min 29 s
sudo make install # ~ 4 min
Save your SD card space:
cd ..
sudo rm -fr ./Python-3.5.2*