En Fri, 16 Nov 2007 00:27:42 -0300, <[EMAIL PROTECTED]> escribió:

> On Nov 1, 11:04 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
> wrote:
>> En Thu, 01 Nov 2007 22:13:35 -0300, <[EMAIL PROTECTED]> escribió:

>> >> I'm in a situation when i don't really need to extend python with any
>> >> classes of my own but
>> >> i do have extra luggage for the python data structures such as  
>> tuples,
>> >> lists, dictionaries, etc
>> >> on the c++ side. I see no place in PyObject_HEAD where i can stick a
>> >> void* to my extra data.
>>
>> Assuming you can recompile all the extensions you use, you could insert
>> your void* into _PyObject_HEAD_EXTRA and _PyObject_EXTRA_INIT
>
> i added two void pointers to head_extra and 0,0, to the extra_init.
> For some reason i get garbage in them from PyEval_EvalCode :-(
> (that's after i blew the build dir and rebuilt 2.4.4 from scratch
> so i don't think i have a bad build)

Can't you use instead the other approaches suggested on this thread? Like  
keeping a weakkey dictionary holding your additional attributes? Seems a  
lot safer to do that way.

I've never changed that headers myself so I can't guarantee it works.  
Perhaps there are some assumptions somewhere in the code about a specific  
layout. But since _PyObject_HEAD_EXTRA is used in the debug build I think  
you should be able to add your own fields, at least in principle...  
Remember that this change invalidates ALL binaries for ANY library or  
extension you may be using. An additional check might be to change the  
Python release number to 2.9.9 or so, so none of your existing extensions  
can inadvertidely be used.

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to