Passing a memory address (pointer) to an extension?
Robert Kern
robert.kern at gmail.com
Wed Oct 22 23:50:23 EDT 2008
John Nagle wrote:
> Philip Semanchuk wrote:
>> I'm writing a Python extension in C that wraps a function which takes
>> a void * as a parameter. (The function is shmat() which attaches a
>> chunk of shared memory to the process at the address supplied by the
>> caller.) I would like to expose this function to Python, but I don't
>> know how to define the interface.
>
> Use message passing, not shared memory. CPython is so slow that you'll
> never notice any performance gain from using shared memory.
>
> Also, if you're asking this question, you probably don't know enough
> to keep out of trouble in this area. You need to thoroughly understand
> concurrency, locking, shared memory locking, the Python Global Interpreter
> Lock, Python memory management, and the implications of the interactions
> between all of them. Otherwise you'll get race conditions, crashes within
> the Python system, lockups, and/or terrible performance.
>
> And none of the usual debugging tools for Python will help you.
I'm pretty sure the OP is fairly aware of the issues involved in shared memory
and the rest.
http://semanchuk.com/philip/posix_ipc/
He's asking about a detail of Python C API for parsing function arguments. His
ignorance in that area doesn't entail ignorance in other matters. You're being
abusive without cause.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list