You should probably first explain your use case -- why is it important to your code to be able to use isinstance() on locks?
On Thu, Mar 29, 2018 at 2:43 AM, Jacco van Dorp <j.van.d...@deonet.nl> wrote: > Currently, you cannot use isinstance checks on threading locks, because > they're created by a factory function instead of being actual classes. > > Now that we've got __subclasshook__ and __instancecheck__, is there > still a reason other than "history" that we can't use isinstance here ? > There > could exist a thin wrapper class along the lines of: > > class Lock: > def __new__(): > return __allocate_lock() # Call factory function > > @classmethod > def __subclasshook__(cls, inst): > # code... > > As far as I can think, no code would be broken by this - even current > introspection > which we're trying to replace would work just fine. > > My C experience is rather limited, so i dont know if it's hard to > write the subclass > /isinstance checks. > > While probably not that important, would people consider this to be a > good idea ? > > (I found this bug report: https://bugs.python.org/issue3352 which has > a post of Nick Coghlan from 2008-07-14 22:25 where this is mentioned > - but in respect to multiprocessing. However, that thread is rather > old and dead. I could not find any other references to this.) > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido)
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/