So, this is the first time I am playing docker on my mac. I used boot2docker
through a standard tutorial and I run a prompt in an ubuntu image.
docker pull ubuntu docker run -i -t ubuntu /bin/bash
When in docker, I started my first experiment to see if performance would decrease. From the command line, I would use the python timeit
module to quickly check some basic performance metrics.
Python Mac Results
$ python3.4 -m timeit '"-".join(str(n) for n in range(100))' 10000 loops, best of 3: 37.7 usec per loop $ python3.4 -m timeit '"-".join([str(n) for n in range(100)])' 10000 loops, best of 3: 34.2 usec per loop $ python3.4 -m timeit '"-".join(map(str, range(100)))' 10000 loops, best of 3: 26.2 usec per loop
Python Docker Results
> python3 -m timeit '"-".join(str(n) for n in range(100))' 10000 loops, best of 3: 30 usec per loop > python3 -m timeit '"-".join([str(n) for n in range(100)])' 10000 loops, best of 3: 26.9 usec per loop > python3 -m timeit '"-".join(map(str, range(100)))' 10000 loops, best of 3: 20.2 usec per loop
It seems strange that docker ubuntu, which runs on top of my mac, actually runs python code faster than python on mac. Is there a reason why this could be?
Edits
I can confirm that both versions of python work in 64 bit.
Mac python
python3 -c 'import sys;print("%x" % sys.maxsize, sys.maxsize > 2**32)' 7fffffffffffffff True
Ubuntu python
python3.4 -c 'import sys;print("%x" % sys.maxsize, sys.maxsize > 2**32)' 7fffffffffffffff True