mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[3.13] Remove outdated note about instance methods from datamodel.rst (GH-122471) (#122479)
Remove outdated note about instance methods from datamodel.rst (GH-122471)
(cherry picked from commit c68cb8e0c9
)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
This commit is contained in:
parent
7a90d94df7
commit
e65aea96c3
1 changed files with 1 additions and 8 deletions
|
@ -727,14 +727,7 @@ When an instance method object is derived from a :class:`classmethod` object, th
|
||||||
itself, so that calling either ``x.f(1)`` or ``C.f(1)`` is equivalent to
|
itself, so that calling either ``x.f(1)`` or ``C.f(1)`` is equivalent to
|
||||||
calling ``f(C,1)`` where ``f`` is the underlying function.
|
calling ``f(C,1)`` where ``f`` is the underlying function.
|
||||||
|
|
||||||
Note that the transformation from :ref:`function object <user-defined-funcs>`
|
It is important to note that user-defined functions
|
||||||
to instance method
|
|
||||||
object happens each time the attribute is retrieved from the instance. In
|
|
||||||
some cases, a fruitful optimization is to assign the attribute to a local
|
|
||||||
variable and call that local variable. Also notice that this
|
|
||||||
transformation only happens for user-defined functions; other callable
|
|
||||||
objects (and all non-callable objects) are retrieved without
|
|
||||||
transformation. It is also important to note that user-defined functions
|
|
||||||
which are attributes of a class instance are not converted to bound
|
which are attributes of a class instance are not converted to bound
|
||||||
methods; this *only* happens when the function is an attribute of the
|
methods; this *only* happens when the function is an attribute of the
|
||||||
class.
|
class.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue