# HG changeset patch # User wheerd # Date 1485500891 -3600 # Fri Jan 27 08:08:11 2017 +0100 # Node ID 541d949460b5a1bd4474ea504f284d9ecc3bb48d # Parent 34fb29694c7640ad3718adcb7756f05b29070da6 Added SlotWrapperType and MethodWrapperType to the types module. diff -r 34fb29694c76 -r 541d949460b5 Doc/library/types.rst --- a/Doc/library/types.rst Wed Jan 25 23:35:46 2017 -0800 +++ b/Doc/library/types.rst Fri Jan 27 08:08:11 2017 +0100 @@ -132,6 +132,13 @@ C".) +.. data:: SlotWrapperType + MethodWrapperType + + The type of methods of some fundamental built-in data types and base classes (such as :meth:`object.__init__` or `object.__lt__`). + The second one is the type of these methods once they are bound to an instance. + + .. class:: ModuleType(name, doc=None) The type of :term:`modules `. Constructor takes the name of the diff -r 34fb29694c76 -r 541d949460b5 Lib/test/test_types.py --- a/Lib/test/test_types.py Wed Jan 25 23:35:46 2017 -0800 +++ b/Lib/test/test_types.py Fri Jan 27 08:08:11 2017 +0100 @@ -575,6 +575,10 @@ def test_internal_sizes(self): self.assertGreater(object.__basicsize__, 0) self.assertGreater(tuple.__itemsize__, 0) + + def test_slot_wrapper_types(self): + self.assertIsInstance(int.__lt__, types.SlotWrapperType) + self.assertIsInstance((42).__lt__, types.MethodWrapperType) class MappingProxyTests(unittest.TestCase): diff -r 34fb29694c76 -r 541d949460b5 Lib/types.py --- a/Lib/types.py Wed Jan 25 23:35:46 2017 -0800 +++ b/Lib/types.py Fri Jan 27 08:08:11 2017 +0100 @@ -36,6 +36,9 @@ BuiltinFunctionType = type(len) BuiltinMethodType = type([].append) # Same as BuiltinFunctionType +SlotWrapperType = type(object.__init__) +MethodWrapperType = type(object().__str__) + ModuleType = type(sys) try: