win32api --with-pymalloc

Mark Hammond mhammond at skippinet.com.au
Thu Jan 24 04:42:17 CET 2002


Alois Goller wrote:
> Hi,
> 
> I try to compile Python 2.1.2 under Windows with WITH_PYMALLOC defined. This
> works fine, but I read that there might be problems with python extensions.
> Well, I want to use  win32api and win32con in my code, too.

I've never tried, but would be interested to hear any results.  I can't 
be bothered rebuilding my entire world just to try :)


> Neil Schemenauer wrote:
> 
>>Using pymalloc with threads should be safe as long as you don't have
>>extensions that call pymalloc without the big lock held.
>>
> 
> How do I see whether "the big lock" is held? Can I use Mark Hammond's win32
> extensions together with WITH_PYMALLOC ?

The win32 extensions *should* work fine here.  They generally grab the 
lock before doing much at all.  Further, a quick look at PyMalloc shows 
it doesn't attempt to redefine any non-Python memory allocators (such as 
global new or free) so should be perfectly fine.

However, the way I see it, that would make PyMalloc just as thread-safe 
as Python itself; the GIL should be held before calling any Python 
functions, including explicit or implicit object creation or destruction.

Mark.




More information about the Python-list mailing list