summaryrefslogtreecommitdiffstats
path: root/Doc/c-api
diff options
context:
space:
mode:
authorJeroen Demeyer <J.Demeyer@UGent.be>2019-05-28 12:42:53 (GMT)
committerPetr Viktorin <encukou@gmail.com>2019-05-28 12:42:53 (GMT)
commiteb65e2443ac21739baf6d373abc7b4638b9d6927 (patch)
tree2197fa4322a60cbe077dfb8c03e0287cd3baabd9 /Doc/c-api
parent0811f2d81a12a3415dc2cb2744b41520c48d4db5 (diff)
downloadcpython-eb65e2443ac21739baf6d373abc7b4638b9d6927.zip
cpython-eb65e2443ac21739baf6d373abc7b4638b9d6927.tar.gz
cpython-eb65e2443ac21739baf6d373abc7b4638b9d6927.tar.bz2
bpo-36922: implement PEP-590 Py_TPFLAGS_METHOD_DESCRIPTOR (GH-13338)
Co-authored-by: Mark Shannon <mark@hotpy.org>
Diffstat (limited to 'Doc/c-api')
-rw-r--r--Doc/c-api/typeobj.rst26
1 files changed, 26 insertions, 0 deletions
diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst
index e0ea9b9..aa66784 100644
--- a/Doc/c-api/typeobj.rst
+++ b/Doc/c-api/typeobj.rst
@@ -1045,6 +1045,32 @@ and :c:type:`PyType_Type` effectively act as defaults.)
???
+
+ .. data:: Py_TPFLAGS_METHOD_DESCRIPTOR
+
+ This bit indicates that objects behave like unbound methods.
+
+ If this flag is set for ``type(meth)``, then:
+
+ - ``meth.__get__(obj, cls)(*args, **kwds)`` (with ``obj`` not None)
+ must be equivalent to ``meth(obj, *args, **kwds)``.
+
+ - ``meth.__get__(None, cls)(*args, **kwds)``
+ must be equivalent to ``meth(*args, **kwds)``.
+
+ This flag enables an optimization for typical method calls like
+ ``obj.meth()``: it avoids creating a temporary "bound method" object for
+ ``obj.meth``.
+
+ .. versionadded:: 3.8
+
+ **Inheritance:**
+
+ This flag is never inherited by heap types.
+ For extension types, it is inherited whenever
+ :c:member:`~PyTypeObject.tp_descr_get` is inherited.
+
+
.. XXX Document more flags here?