Question

I wrote some custom code that uses locks and condition variables, I observe significant difference in synchronisation overhead between Python 2.x and 3.x:

  • 2.6.8, 2.7.6: 14~54ms
  • 3.3.4: <1ms

Is there a reason for this? A well-known explanation? A CPython bug only solved in 3.x?

If someone knows the answer off the top of their head, it's most welcome.

Otherwise leave a comment and I'll hack up some test code.

Was it helpful?

Solution

They did a lot of work in 3.2 to improve multithreading performance and how the GIL functions:

http://docs.python.org/dev/whatsnew/3.2.html#multi-threading

Without knowing anything else about your code, that'd be my guess.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top