In PEP 573, instead of passing the defining class to the C function, why not pass the function object itself? That is far more general: once you have the function object, you can still access the defining class using your PyCMethod_CLASS. It's also more future-proof: if we ever decide to add even more attributes to the function object, those could be accessed the same way.

In PEP 575, I'm already proposing a flag (METH_ARG0_FUNCTION) to pass the function *instead* of self. Unless PEP 573 is rejected, maybe that should change to passing the function *in addition* to self.

Of course, this doesn't quite work with your current version of PEP 573 since METH_METHOD really does two things: it changes the class of the function object (which is not a good idea anyway) and it changes the calling convention. It could work if you add mm_class to PyCFunctionObject instead of creating a new class.


Jeroen.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to