building python from source
prepare installing packages (assuming Ubuntu environment)
$ sudo apt install build-essential
$ sudo apt install libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev
$ sudo apt install libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev libffi-dev tk-dev
download and installing python source
$ tar -xf Python-src.tar.xz
$ cd Python-??
$ ./configure --enable-optimizations
$ make -j 8
$ sudo make altinstall
altinstall
is recommended in order to avoid messing up the existing python executable.