Python's biggest compromises

Aahz aahz at pythoncraft.com
Wed Aug 6 20:10:20 EDT 2003


In article <uznim5ynx.fsf at online.no>,
Syver Enstad  <syver-en+usenet at online.no> wrote:
>aahz at pythoncraft.com (Aahz) writes:
>>
>> (Yes, there are issues with Python on SMP machines, but to call
>> Python's built-in threading "non-existent SMP scalability" is either
>> a lie or revelatory of near-complete ignorance.  That doesn't even
>> count the various IPC mechanisms.)
>
>It's an interesting subject though. How does python threading on SMP
>machines compare with f.ex. Java and C++. I know that at least the
>MSVC compiler has a GIL like problem with heap access (new, malloc,
>delete, free), which is guarded with a global lock. 

Sure, but that's not where a C++ application usually spends its time.

>Would migrating the global data for a thread to some sort of thread
>local storage help Python SMP performance? If Java has better
>threading performance than Python how have they solved the interpreter
>state problem. Java is interpreted isn't it?

Well, that's a good question.  *Does* Java have better threading
performance than Python?  If it does, to what extent is that performance
bought at the cost of complexity for the programmer?  

Keep in mind that the GIL exists not because of issues with thread-local
storage but because every Python object is global and can have bindings
to it in any -- or every -- thread.  Python uses objects *everywhere*;
the GC uses Python objects, stack frames are Python objects, modules are
Python objects.  To create "thread-local" storage as you suggest would
require a wholesale revision of Python's object model that would make it
something other than what Python is today.

Based on recent discussions about restricted execution, I suspect that
security would be much more likely to drive such changes; if that
happens, perhaps revisiting the way GIL works might happen with it.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

This is Python.  We don't care much about theory, except where it intersects 
with useful practice.  --Aahz




More information about the Python-list mailing list