Re: How do I add method dynamically to module using C API?

2010-07-08 Thread Alf P. Steinbach /Usenet
* Martin v. Loewis, on 08.07.2010 07:23: And since things work for a single method when I declare 'def' as 'static', I suspect that means that the function object created by PyCFunction_NewEx holds on to a pointer to the PyMethodDef structure? Correct; it doesn't make a copy of the struct. So

Re: How do I add method dynamically to module using C API?

2010-07-08 Thread Martin v. Loewis
I tried (1) adding a __del__, but no dice, I guess because it wasn't really an object method but just a free function in a module; and (2) the m_free callback in the module definition structure, but it was not called. m_free will be called if the module object gets deallocated. So if m_free

Re: How do I add method dynamically to module using C API?

2010-07-08 Thread Alf P. Steinbach /Usenet
* Martin v. Loewis, on 08.07.2010 09:13: I tried (1) adding a __del__, but no dice, I guess because it wasn't really an object method but just a free function in a module; and (2) the m_free callback in the module definition structure, but it was not called. m_free will be called if the module

How do I add method dynamically to module using C API?

2010-07-07 Thread Alf P. Steinbach /Usenet
The code below, very much work in progress, just trying things, is C++. Sorry about the formatting, I had to reformat manually for this posting: code class Module { private: Ptr p_; public: Module( PyModuleDef const def ) : p_(

Re: How do I add method dynamically to module using C API?

2010-07-07 Thread Martin v. Loewis
And since things work for a single method when I declare 'def' as 'static', I suspect that means that the function object created by PyCFunction_NewEx holds on to a pointer to the PyMethodDef structure? Correct; it doesn't make a copy of the struct. So when you want the function object to