Embedding: Howto get object's dictonary

O

Oliver Eichler

Hi,

having a PyObject pointer to a python object, how can I get the object's
dictionary, if there is any. There seems to be _PyObject_GetDictPtr() but
this looks quite like a internal "you must not use it".

Thanks for help

Oliver
 
F

Fredrik Lundh

Oliver said:
having a PyObject pointer to a python object, how can I get the object's
dictionary, if there is any. There seems to be _PyObject_GetDictPtr() but
this looks quite like a internal "you must not use it".

I'd say it's more of an "be very careful", along the lines of _PyString_Resize,
_PyTuple_Resize, and other functions that can cause all sorts of trouble if you
use them carelessly.

(note btw that the function returns a pointer to the dictionary pointer, not the
dictionary itself)

</F>
 
O

Oliver Eichler

Fredrik said:
I'd say it's more of an "be very careful", along the lines of
_PyString_Resize, _PyTuple_Resize, and other functions that can cause all
sorts of trouble if you use them carelessly.

(note btw that the function returns a pointer to the dictionary pointer,
not the dictionary itself)
yep, I've noticed. Leaving me still with the uncertain feeling wether there
is a better way to get the dict, or not. I mean, why is there no
PyObject_GetDictPtr() returning a new or borrowed reference? Any other
reason than "Nobody did implement it, so far."?


Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top