mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
bpo-36922: implement PEP-590 Py_TPFLAGS_METHOD_DESCRIPTOR (GH-13338)
Co-authored-by: Mark Shannon <mark@hotpy.org>
This commit is contained in:
parent
0811f2d81a
commit
eb65e2443a
10 changed files with 132 additions and 7 deletions
|
|
@ -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?
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue