[Python-Dev] PEP 573 -- Module State Access from C Extension Methods

Jeroen Demeyer J.Demeyer at UGent.be
Tue Apr 24 10:34:04 EDT 2018


On 2018-04-24 14:53, Nick Coghlan wrote:
>> 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.
>
> That would definitely be an elegant way of addressing both use cases.

On the other hand, if you are passing the function object, then you can 
get __self__ from it (unless it's an unbound method: in that case 
__self__ is NULL and self is really args[0]). So there wouldn't be a 
need for passing "self". I'm not saying that this is better than passing 
"self" explicitly... I haven't yet decided what is best.

In any case, these things would be handled by Argument Clinic anyway, so 
it only matters if you are parsing arguments "by hand".


Jeroen.


More information about the Python-Dev mailing list