ob_type in shared memory

Aaron Brady castironpi at gmail.com
Mon Jan 26 01:06:43 CET 2009


Hello,

I am writing an extension using shared memory.  I need a data type
that is able to reassign its 'ob_type' field depending on what process
is calling it.

Object 'A' is of type 'Ta'.  When process 'P' is looking at it, it
needs to have an 'ob_type' that is 'Ta' as process 'P' sees it.  When
process 'Q' is looking at it, it needs to have an 'ob_type' that is
'Ta' as process 'Q' sees it.  If it referred to 'Ta' in process 'P'
when 'Q' was calling it, 'Q' would have to access memory that is in
another process.

Therefore, I need a field and an array.  The field indicates which
type should be loaded, and the array contains the types.  Quick
example:

PyTypeObject* array_of_types[]= { &SharedList, &SharedTuple };

Then, when a list is being accessed, it can set its own 'ob_type'
field to 'array_of_types[ 0 ]', and similarly for a tuple.

However, I'm having trouble getting 'array_of_types' in the right
module during compilation.  My question is: Where do 'array_of_types'
and the forward declarations for the types go?

My fallback is what 'pickle' does: store types as strings, then load
them dynamically for 'ob_type'.  That is, obtain a pointer to the type
from the string.

Thank you for reading!  Any ideas?  Thanks in advance.



More information about the Python-list mailing list