I just killed GIL!!!

sturlamolden sturlamolden at yahoo.no
Thu Apr 17 12:48:42 EDT 2008


On Apr 17, 5:46 pm, Hrvoje Niksic <hnik... at xemacs.org> wrote:

> Have you tackled the communication problem?  The way I see it, one
> interpreter cannot "see" objects created in the other because they
> have separate pools of ... everything.  They can communicate by
> passing serialized objects through ctypes, but that sounds like the
> solutions that use processes.

I see two solutions to that.

It is possible to use fine-grained locking on the objects that need to
be communicated. ctypes can pass PyObject* pointers
(ctypes.py_object), or we could resort to some C. When interpreter A
get a PyObject* pointer from B (a total of four bytes on my computer),
interpreter A can:

(1) Acquire B's GIL
(2) Increment the refcount of the PyObject*
(3) Release B's GIL
(4) Use the object as its own (synchronization is required)

Sharing PyObject* pointer has the possibility of shooting your leg
off. But I believe the small quirks can be worked out.

The other option is to use serialized Queues like the processing
module in cheese shop. I don't think it will be faster than similar
mechanisms based on IPC, because object serialization and
deserialization are the more expensive parts.











More information about the Python-list mailing list