python - Is there a method to convert PyUnicodeObject variable to PyObject type? -


Is there a conversion method for PyunicodeObject that needs to pass the value PyObject variable?

Thanks Colonel

You can just use this for your purpose An artist in C code:

  PyUnicodeObject * p = ... whatever ...; Callomefun ((PyObject *) P);  

All specific, solid type PyWhateverObject can be considered as being "derived" from PyObject, now C is the concept of heritage, hence anybody in it Not "derived", but Python VM synthesizes with the memory layout of each object type, which starts with a heading that will be PyObject (macro for this) ). It guarantees that the casting of normal coatings (although technically as a "risky" compiler, he can not check accurately - if you put the wrong thing, you will crash only during the runtime ;-) A pointer Works correctly when used with PyObject and any indicator for a specific, concrete Python type structure.


Comments