PyCFunction_New requires a pointer to a static PyMethodDef?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben Sizer

    #1

    PyCFunction_New requires a pointer to a static PyMethodDef?

    In following the example given at
    <http://aspn.activestat e.com/ASPN/Cookbook/Python/Recipe/54352>, I find
    that if I instead try to create PyMethodDef instances on the stack and
    create methods that way, rather than providing pointers to a static
    array of them, executing the method later raises an exception from
    PyCFunction_Cal l.

    Is it required that the PyMethodDef persists throughout the execution
    of the Python program? If so, why isn't the information just copied
    instead? I was hoping to just create a temporary PyMethodDef on the
    stack purely for the duration of creating the method.

    (Google doesn't find any instance of "PyCFunction_Ca ll" on
    docs.python.org . This might explain the Cookbook's comment that "one
    hardly ever sees Python class objects built in C extensions"!)

    --
    Ben Sizer

Working...