git.net

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

[Python-Dev] Deprecating "instance method" class


On 04/04/2019 13.51, Jeroen Demeyer wrote:
> During my investigations related to low-level function/method classes, I
> came across the "instance method" class. There is a C API for it:
> https://docs.python.org/3.7/c-api/method.html
> However, it's not used/exposed anywhere in CPython, except as
> _testcapi.instancemethod (for testing its functionality)
> 
> This class was discussed at
> https://mail.python.org/pipermail/python-3000/2007-December/011456.html
> and implemented in https://bugs.python.org/issue1587
> Reading that old thread, there are use cases presented related to
> classic classes, wrapping Kogut
> (http://kokogut.sourceforge.net/kogut.html) objects and Pyrex. But
> classic classes no longer exist and the latter two use cases aren't
> actually needed if you read the thread to the end. So there are no
> surviving use cases from that thread.
> 
> Does anybody know actual use cases or any code in the wild using it? To
> me, the fact that it's only exposed in the C API is a good sign that
> it's not really useful.

You are drawing the wrong conclusion here. The feature was explicitly
designed for C code and C API wrappers like swig and Cython to make
adaption to Python 3 simpler. I implemented it when I removed unbound
methods.

> So, should we deprecate the instance method class?

I couldn't find any current code that uses PyInstanceMethod_New. Let's
deprecate the feature and schedule it for removal in 3.10.

Christian