running time of python program is very small in ubuntu as compare to windows. why?
Question: I implemented [Dijkstra's
algorithm](http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm) in Python and
ran the script under Ubuntu and windows 8. Both x64 architecture.

I profiled the script using `python -m cProfile name.py`

I was surprised to see that program took half the time in Ubuntu compared to
Windows.

Ubuntu run time for 1000 x 1000 matrix : `0.4 sec`

Windows run time for 1000 x 1000 matrix = `1.2 sec`

This is on the same, dual booted, machine.

How this is happening ?


Answer: First - the obvious is that while the versions of python might be the same,
they have been compiled with different compilers and naturally that means the
optimization levels are completely different. You could recompile python for
both systems using gcc for example and run the whole thing again. However I
will advise you to do this only if you are sure about what you are doing. More
specifically for linux since many of the processes which run depend heavily on
python. Take a look at [this](http://stackoverflow.com/questions/10150881/why-
is-python-so-much-slower-on-windows) discussion.

Second - windows naturally takes up a lot more resources than linux and out of
the box windows starts significantly more processes and every process is
generally an infinite loop, taking up resources.

Comparing performance based on OS is a wrong concept. It's basically like
comparing apples to oranges. Each system has different ways of managing it's
memory and the running processes. The file system is another very important
part - since python is in most cases an interpreted language, each import is
performing disk operations.

