osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] Deprecating "instance method" class


05.04.19 14:27, Jeroen Demeyer ????:
> On 2019-04-05 14:10, Serhiy Storchaka wrote:
>> it can be used to
>> implement accelerated versions of separate methods instead of the whole
>> class.
> 
> Could you elaborate? I'm curious what you mean.

It is easy to implement a function in C. But there is a difference 
between functions implemented in Python and C -- the latter are not 
descriptors. They behave like static methods when assigned to a class 
attribute, i.e. there is no implicit passing of the "self" argument.

>> I'm going to use it to further optimize total_ordering.
> 
> There are so many ways in which total_ordering is inefficient. If you 
> really want it to be efficient, you should just implement it in C.

Yes, this is what I want to do. I did not do this only because 
implementing method-like functions which which do not belong to concrete 
class implemented in C is not convention. But PyInstanceMethod_New() 
should help.