Sturla Molden skrev:
> I have always believed PyMem_Malloc call PyArena_Malloc with Python's 
> heap as arena. PyArena_Malloc is a non-threadsafe reimplementation of 
> malloc.
>
> I have a problem finding PyMem_Malloc in Python sources.
>
>   

In normal mode we have a direct call to malloc, which don't require the GIL if 
libc is thread-safe:

void *
PyMem_Malloc(size_t nbytes)
{
        return PyMem_MALLOC(nbytes);
}

#define PyMem_MALLOC(n)         (((n) < 0 || (n) > PY_SSIZE_T_MAX) ? NULL \
                                : malloc((n) ? (n) : 1))


In debug mode, PyMem_Malloc finally becomes a call to PyObject_Malloc,  
which requires the GIL.



S.M.
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to